I have been trying to make a simple game in Python 3.3.4, at the beginning of the game I want the user to select a difficulty between 1 and 3 and if they put in another character other than 1, 2 or 3 they receive the message 'Invalid input'.
I have written the code below, however I cannot get it to function correctly in the even if the user does input 1, 2 or 3 it will come up with the error 'invalid input', I have tried messing around with it in various combinations with no avail. I understand that this is rather basic an probably something simple that I am overlooking as I am new to Python. Thanks in advance.
while True:
while True:
cmd = input('Please select a diffuculty from 1 to 3, with three being the hardest: ')
if cmd in (1, 2, 3):
break
print ('Invalid input.')
if cmd == 1:
dopt = 3
continue
elif cmd == 2:
dopt = 4
continue
elif cmd == 2:
dopt = 5
continue