Nick1980
Nick1980

Reputation: 17

Python changing a int during an operation

I am trying to loop a script but I want "a" to become whatever "b" ends up being. For eample if my input is 10 b=1000... I then loop it back but want "a" to become 1000 (what b ended up as)....

import threading
import time
while True:
    print time.time ()
    a=900 
    input=int(raw_input("enter a number,"))
    b=int(((input-5)*20)+a)
    print b

Upvotes: 0

Views: 55

Answers (1)

Femaref
Femaref

Reputation: 61457

Define a outside the loop:

import threading
import time
a=900
while True:
    print time.time ()
    input=int(raw_input("enter a number,"))
    b=int(((input-5)*20)+a)
    a = b
    print b

Upvotes: 3

Related Questions