← Back to challenges

Position in the Alphabet

PythonHardnumberslanguage_fundamentals

Instructions

Given a number between 1-26, return what letter is at that position in the alphabet. Return "invalid" if the number given is not within that range, or isn't an integer.

Examples

letter_at_position(1) ➞ "a"

letter_at_position(26.0) ➞ "z"

letter_at_position(0) ➞ "invalid"

letter_at_position(4.5) ➞ "invalid"

Notes

  • Return a lowercase letter.
  • Numbers that end with ".0" are valid.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Flick Switch