Ask Question
3 November, 07:29

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]))

+2
Answers (1)
  1. 3 November, 08:22
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers