Character Encoder / Decoder

Write a function encode_decode(mode, value) where:

  • if mode is "encode", value is a single character and the function returns its character code as an integer (use ord).
  • if mode is "decode", value is a code point (as a string of digits) and the function returns the character it represents (use chr).

Read mode then value from input, and print the result.

Example: input encode, A → output 65. Input decode, 66 → output B.

main.py
Loading editor…

Console

Run your code to see output here.