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

+1
Answers (1)
  1. 27 November, 17:36
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers