Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python: Write a program using the ord function: it should take a character as input and output the corresponding number (between 1 and 26). Your
Python: Write a program using the "ord" function: it should take a character as input and output the corresponding number (between 1 and 26). Your program should only accept capital letters. As error-checking, print invalid if the input is not a capital letter.
#my code. Can't seem to get it to work correctly
# I keep getting hung up when "@" is the input
letter = input() if (len(letter) > 1 or letter != letter.upper()) or letter != letter.isalpha(): print("invalid input") else: print(ord(letter)-ord("A")+1)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started