word = input('Please write a word:')
length_word = len(word)
index = length_word - 1
x = 1
restart_variable = 1
while x != 0:
try:
while index >= 0:
letter = word[index]
print(letter)
index = index - 1
except:
print('Please enter a word')
while restart_variable != 0:
end_program = input('Would you like to restart the program? (Y/N) ')
if end_program == 'Y' or end_program == 'y':
break
elif end_program == 'N' or end_program == 'n':
x = 0
restart_variable = 0
break
elif end_program != ('Y'or'N') or end_program != ('y' or 'n'):
print('Please enter specified commands.')
continue
print('Goodbye!')
input('Press enter to exit the terminal')
Hi!
I have tried to build this word reverser program, but when i press y/Y (which should make the program restart) and try to restart the program i am brought back to the "while restart_variable" loop.
This input however should make the program restart. What am i missing?
Thanks to everyone who will answer!