I have been set a simple task:
Write a program for a game where the computer generates a random starting number between 20 and 30. The player and the computer can remove 1,2 or 3 from the number in turns. Something like this... Starting number : 25 How many do you want to remove? 3 22 left Computer removes 2 20 left The player who has to remove the last value to bring the number down to 0 is the loser. 1 left Computer removes 1 You win!
I am trying to create it so that the player can only enter numbers 1, 2 or 3 to remove.
I get the syntax error of invalid syntax where the if statement is:
import random
import time
start=random.randint(20,30)
print('Starting number is',start)
personremove=int(input('How many do you want to remove? '))
if personremove=<3 or >1:
print('Enter a number between 1 and 3')
personremove=int(input('How many do you want to remove? '))
current=start-personremove
print(current,'left')
compremove=random.randint(1,3)
current=start-personremove-compremove
print('Computer removes',compremove)
print(current,'left')
Any help would be greatly appreciated, I am only a beginner to python as you can probably tell.
if personremove=<3 or >1:this isn't valid Python.