The code is buggy and is doing things randomly to the input; perheaps I'm missing as to how Python iterates through loops.
Feels like it'd work if I create a new variable. Or maybe if I only used an else nested in an if but not an else. But why is this not working, and why is the variable not updating? Please be kind as to offer some insight.
#we keep adding
#if input == 77 it breaks
#else number we keep updating stored variable and keep showing total
number_1 = 0
while True:
number_1 =int(input("Give a number to add.."))
if number_1 == 77:
break
else:
number_1=number_1 + number_1
print('your total now is:',number_1)
Thanks,and sorry if this seems obvious.
Aucun commentaire:
Enregistrer un commentaire