I'm quite new to Python (and programming past pascal) so I'm looking for a relatively simple-to-understand way to do this. All help is much appreciated.
I'm looking for the program to take a variable as if it were just normal code, I'll explain via example.
I want the code to access this:
where move1 can be from 1 to 4.
I have a function to calculate what move to use, and that returns either, move1, move2, move3 or move4.
I'm looking for some way to make something like this work:
Where chosenMove is a string containing either move1, move2, move3 or move4.
I know I could make 4 if statements (I read that Python can't do case statements?)
if chosenMove == move1: moves.movesCustom.move1; if chosenMove == move2: ...
but that doesn't seem very efficient. Is there a better way to do this?
Thanks in advance.