14th Sep 2017, 3:56 PM
Sqad0ra
Sqad0ra - avatar
5 Réponses
+ 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 '='.
14th Sep 2017, 4:06 PM
Dev
Dev - avatar
+ 2
Updated: now it's complete and able to restart :p .
14th Sep 2017, 5:11 PM
Sqad0ra
Sqad0ra - avatar
+ 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
14th Sep 2017, 4:12 PM
Paul Osakue
Paul Osakue - avatar
0
I think I'll try this code
14th Sep 2017, 4:02 PM
Paul Osakue
Paul Osakue - avatar
- 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.
14th Sep 2017, 4:28 PM
sayan chandra
sayan chandra - avatar