University of Arizona, Department of Computer Science

CSc 120: Number to Letter

Expected Behavior

Write a function number2letter(n), where n is an integer between 0 and 25, that returns the lower-case letter at position n. Here, 'a' is at position 0, 'b' is at position 1, 'c' is at position 2, ... 'z' is at position 25.

Programming Comments

The simplest way to solve this problem is using one or more of the constants defined in Python's string module (documented here). If you know how the ASCII characters are organized, you can also use the chr() builtin function. Or you can just program it up yourself, it shouldn't take you more than a line or two of code.

Examples

  1. number2letter(3)
    return value: 'd'

  2. number2letter(17)
    return value: 'r'