import random
thenum = random.randint(1000, 9999)
print (thenum)
tally = 1
guessone = int(input("What is your first guess?: "))
strguessone = str(guessone)
strthenum = str(thenum)
if strguessone [0] == strthenum [0]:
tally + 1
if strguessone [1] == strthenum [1]:
tally + 1
if strguessone [2] == strthenum [2]:
tally + 1
if strguessone [3] == strthenum [3]:
tally + 1
print (tally)
if tally == 5:
print ("You Win")
When I run this code I only get a response of one from the print tally why is that I add the tally within the if statements I know that I should be using loops but I figured this is what i want to do
Aucun commentaire:
Enregistrer un commentaire