You can implement the following (mentioned in other answers, but I will try to explain how it is working):
The `string` module has a function called [`ascii_uppercase`][1] and a function called [`ascii_lowercase`][2]. What they do is return a string containing the alphabet. Like so:
```
>>> import string
>>> string.ascii_uppercase
ABCDEFGHIJKLMNOQRSTUVWXYZ
>>> string.ascii_lowercase
abcdefghijklmnoqrstuvwxyz
```
If you want to get the letter corresponding to a number, you can use [string slicing][3] to do so. Meaning, if you want to convert '1' into a letter, get the 1th letter in the string, which would be 'a'.
However, when slicing strings they start from 0, not 1. Meaning, if we had a variable containing a string with the alphabet (`letters = "abcdefghijklmnoqrstuvwxyz"`), `letters[1]` would be 'b'; to get 'a, we'd need `letters[0]`. So to get the letter corresponding to 1 we'd need the letter at index 0, to get the letter corresponding to 2 we'd need the letter at index 1, etc.
So, the following code would return the letter corresponding to a number:
```
import string
number = 4
letter = string.ascii_lowercase[number-1]
print (letter)
```
This would output:
```
>>> d
```
You can also package this info a function:
```
import string
def get_letter(number=int):
letter = string.ascii_lowercase[number-1]
return letter
```
So running `print(get_letter(4))` would return `>>> c`.
[1]: https://docs.python.org/3/library/string.html#string.ascii_uppercase
[2]: https://docs.python.org/3/library/string.html#string.ascii_lowercase
[3]: https://www.geeksforgeeks.org/how-to-index-and-slice-strings-in-python/
You can implement the following:
The `string` module has a function called [`ascii_uppercase`][1] and a function called [`ascii_lowercase`][2]. What they do is return a string containing the alphabet. Like so:
```
>>> import string
>>> string.ascii_uppercase
ABCDEFGHIJKLMNOQRSTUVWXYZ
>>> string.ascii_lowercase
abcdefghijklmnoqrstuvwxyz
```
If you want to get the letter corresponding to a number, you can use [string slicing][3] to do so. Meaning, if you want to convert '1' into a letter, get the 1th letter in the string, which would be 'a'.
However, when slicing strings they start from 0, not 1. Meaning, if we had a variable containing a string with the alphabet (`letters = "abcdefghijklmnoqrstuvwxyz"`), `letters[1]` would be 'b'; to get 'a, we'd need `letters[0]`. So to get the letter corresponding to 1 we'd need the letter at index 0, to get the letter corresponding to 2 we'd need the letter at index 1, etc.
So, the following code would return the letter corresponding to a number:
```
import string
number = 4
letter = string.ascii_lowercase[number-1]
print (letter)
```
This would output:
```
>>> d
```
You can also package this info a function:
```
import string
def get_letter(number=int):
letter = string.ascii_lowercase[number-1]
return letter
```
So running `print(get_letter(4))` would return `>>> c`.
[1]: https://docs.python.org/3/library/string.html#string.ascii_uppercase
[2]: https://docs.python.org/3/library/string.html#string.ascii_lowercase
[3]: https://www.geeksforgeeks.org/how-to-index-and-slice-strings-in-python/