Ask Question
1 March, 06:54

In the last problem, we get an error if we enter more than one character at a time. Rewrite the program so that it only calls the ord method if a single character is entered.

I have this code so far I just don't know how to make it print not a character

ch = input ("Enter a character: ")

print ("ASCII #%d" %ord (ch[0]))

+3
Answers (1)
  1. 1 March, 08:43
    0
    ch = str (input ("Enter a character: "))

    if str. isalpha (ch) = =True:

    print ("ASCII #%d" %ord (ch))

    else:

    print ("Not accepted")

    Explanation:

    Above, we check if the input is an alphabet, and only then ord is called or else Not accepted message is printed.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “In the last problem, we get an error if we enter more than one character at a time. Rewrite the program so that it only calls the ord ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers