I'm very new to python and was wondering if there was a way to convert a series of if statements to two corresponding lists?
To take something like this:
var = int(input("Enter a number: "))
if var == 1:
print("One")
elif var == 2:
print("Two")
elif var == 3:
print("Three")
elif var == 4:
print("Four")
And convert it into something like this:
commandnumber = [1, 2, 3, 4]
command = [("One", "Two", "Three", "Four")]
print(command[commandnumber.index(var)])
I don't know enough about to python to understand if this is even doable or not. I basically want an easier way for a user to input a number and receive a corresponding command (i.e. print or turtle.forward) depending on what number was inputted.
Thank you for your time.