Jan-20-2024, 01:03 AM
This is 'long hand' and could be shorter.
alpha_upper = [chr(n) for n in range(65, 91)] # A...Z alpha_lower = [chr(n) for n in range(97, 123)] # a...z alpha_lst = alpha_lower + alpha_upper alpha_lst.sort() alpha_input = "" while alpha_input not in alpha_lst: alpha_input = input("Enter a letter of the English alphabet: ") index_num = alpha_lst.index(alpha_input) char = alpha_lst[index_num] print(index_num, char)I think it's what you're trying to do.
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein