Skip to content
Advertisement

python: How can I print an alphabet from a list, given a number?

Given a number from 1 to 26, I’m trying to return an alphabet in the corresponding position from a list.

Example:

JavaScript

I have tried the following:

JavaScript

As expected that returns a type error because there are no integer values in my list.

What can I do to return an element from my list in which its position is equal to the users number input?

Advertisement

Answer

Using ASCII conversion from integer to character, you can do it as follows,

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement