I am trying to code a random decision between 3 machines. Since python does not has any switch/case function, i resort to if and elif. Each machine(line1(),line2(),line3() has their own function as well. However I been getting errors.
Please advise me on what is going wrong
machine_choice = [1,2,3]
selected_machine = random.choice(machine_choice)
print(selected_machine)
def machines(selected_machine):
if selected_machine == 1:
print("machine 1 randomly selected")
line1()
elif selected_machine == 2:
print("machine 2 randomly selected")
line2()
else:
print("machine 3 randomly selected")
line3()
machines(selected_machine)
Aucun commentaire:
Enregistrer un commentaire