I quite a beginner to real programming languages and I am using Python to write a long if elif chain to check x and y variables as coordinates and depending on the coordinates it would do something different. (This is for a text-based adventure game)
This is what I have now and I was wondering how I could do it in a much nicer way.
if x == 1 and y == 1:
dothis()
elif x == 1 and y == 2:
dothat()
elif x == 1 and y == 3:
doANewThing()
elif x == 1 and y == 3:
doSomethingDif()
Except this appears over 900 times. I hate it. Please Help.
Aucun commentaire:
Enregistrer un commentaire