Character Encoder / Decoder
Write a function encode_decode(mode, value) where:
- if
modeis"encode",valueis a single character and the function returns its character code as an integer (useord). - if
modeis"decode",valueis a code point (as a string of digits) and the function returns the character it represents (usechr).
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.