0
What's wrong with " if button = 0: " ?
5 Answers
+ 12
if button == 0:
print("Exit!")
running = False
elif button == 1:
print("Restart!")
# You should use the conditional operator instead of the assignment operator i.e. '==' replacing '='.
+ 2
Updated: now it's complete and able to restart :p .
+ 1
a = int(input("Enter a number: "))
b = int(input("Enter an adding number"))
c = int(input("Enter a max number"))
running = True
while running==True and a<=100:
print(a)
a = a + b
if a > c:
continue
button = int(input("Press 1 to restart or 0 to exit"))
if button == 0:
print("Exit!")
running = False
elif button == 1:
print("Restart!")
break
Your former code was a forever loop,, so I added a<=100 do it has a limit.. And I don't understand the function of the script
0
I think I'll try this code
- 1
=
is the value assign operator
==
is the "checking if values of both sides are same" operator
when using if statement
u r not assiging value but checking if the l.h.s and r.h.s values r sane or not
so if / else if these statements use == operator.