original = raw_input('Enter a word:') if len(original) and original.isalpha(): word = original.lower() first=word new_word=word[1:]+first+"ay" print new_word else: print "Unvalid input" original = raw_input('Enter a word:') ====== above is my code how to make the user type again and run the whole program
You could get rid of the last line of code and put everything in a while loop.
Surround it in a function, then run an if statement at the end asking if they want to go again. If they do, call the function again.
Surround it in a while loop or a for loop.
While Loop: Checking a boolean variable, change it to false if they don't want to continue.
For loop: Break from the loop if they don't want to continue - otherwise it will continue a set number of times.
Get it, thanks for your useful info.
Thanks, both of solutions are great.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.