Here is a dumbed down version of my program that I am using as an example.
I know that using GOTO is bad practice, because it leads to sloppy and confusing code, however it would be perfect for solving this problem that I have (problem detailed at bottom of post).
def prompt():
while True:
user_input = raw_input:
if input == '?':
print help_o
elif not user_input.isalpha():
print "You entered bad characters"
elif user_input == 'r': ##Restart
???????????
else:
return user_input
load_word_list() ##Load words into list
for word in wordList: ##Loop that needs to restart
for i in range(5):
to_speak = "Spell, %s" %word
subprocess.Popen(['espeak', to_speak])
answer = prompt()
if answer != word:
print "You got it wrong"
#Print results
At the Prompt, I want to reload the wordList list and restart the outer for loop.
With GOTO I could just put in place of ????… GOTO load_word_list().
But since this is Python (and Python is about good code), What is the Pythonic way to solve this problem?
Another take on jsbuenos solution. This actually does re-run the outer for loop.