← Back to challenges

Find ASCII Charcode of Inverse Case Character

PythonHardstringsformatting

Instructions

Create a function that takes a single character as an argument and returns the char code of its lowercased / uppercased counterpart.

Examples

Given that:
  - "A" char code is: 65
  - "a" char code is: 97

counterpartCharCode("A") ➞ 97

counterpartCharCode("a") ➞ 65

Notes

  • The argument will always be a single character.
  • Not all inputs will have a counterpart (e.g. numbers), in which case return the input's char code.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Sum of Evenly Divisible Numbers from a Range