Apr-20-2017, 09:34 PM
(This post was last modified: Apr-20-2017, 09:34 PM by Luke_Drillbrain.)
I did a lot of programming in MS Visual BASIC 6 way back when. Now I'm getting up to speed in Python. To learn Python's equivalent of If/Then/ElseIf, I've written the following code:
If I mixed in the BASIC "goto" command with this code, it would be like this:
intLangChoice = int(input("Choose your language, 1 for French, 2 for English, 3 for German, or 4 for Spanish. "))
if intLangChoice == 1:
print("On parle en français aujoud'hui.")
elif intLangChoice == 2:
print("We're speaking in English today.")
elif intLangChoice == 3:
print("Wir sprechen heute auf Deutsch.")
elif intLangChoice == 4:
print("Hoy hablamos en español.")
else:
print("You didn't choose a language.")It's a good start. It runs. However, I would like to make them choose a language if they put something in other than 1, 2, 3, or 4. If they put in 5 or higher, they'll get "You didn't choose a language." At that point, I'd like to send them back to the beginning of the code where it says, "Choose your language, 1 for French, 2 for English, 3 for German, or 4 for Spanish." If I mixed in the BASIC "goto" command with this code, it would be like this:
TheTop:
intLangChoice = int(input("Choose your language, 1 for French, 2 for English, 3 for German, or 4 for Spanish. "))
if intLangChoice == 1:
print("On parle en français aujoud'hui.")
elif intLangChoice == 2:
print("We're speaking in English today.")
elif intLangChoice == 3:
print("Wir sprechen heute auf Deutsch.")
elif intLangChoice == 4:
print("Hoy hablamos en español.")
else:
print("You didn't choose a language.")
GoTo TheTopI googled around, but what I found didn't run.
