Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions