Loop or erase raw_input


My code seems to work well, but not perfect. When I input an integer value or special character it prints the else statement but also still prints the original statement. How would I either, loop back to the original question and ask for a new word, or display only that a valid word was not input? Probably a little ahead of this current training but not too far ahead… thanks for any input!

pyg = 'ay’
original = raw_input(‘Enter a word:’)

if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
print original
print ‘Enter a valid word’

new_word = word[1:] + first + pyg
print new_word


Ask someone who is good at coding.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.