I'm newbie. I'm trying to find out a solution to an exercise but i'm not so skilled and I made several attempts with no results.
I have to write sort of a game. To start, the computer has to ask you to decide a number X. If the number is a multiple of 4 the user starts. Otherwise the computer will. Taking turn, computer and user subctract a number from 1 to 3 to "X" and get a value Z. The one who wins the game subtracts the latest balls and lets with no balls to pick the other contestant (in this case the user). I have to write everything in a fashion that the computer will get the wins, always. Below, the code I have so far written.
Any hint?
x = int(input("how many marbles?"))
if x%4==0:
print("you start")
y = int(input("subtract 1 or 2 or 3 marbles: "))
z=x-y
print("there are ",z," marbles left")
else:
print("computer starts")
if x==x+3:
m=x-3
print("there are ",m," marbles left")
if x==x+2:
m=x-2
print("there are ",m," marbles left")
if x==x+1:
m=x-1
print("there are ",m," marbles left")
Aucun commentaire:
Enregistrer un commentaire