Wednesday, 15 April 2015

Python global variables aren't working in a loop -



Python global variables aren't working in a loop -

i=-1 while true: global ++i if i>5: break print

i want print 0 1 2 3 4, prints 0 0 0 time. how prepare this?

you not changing variable i

i=-1 while true: global i+= 1 #<----- if i>5: break print

python

No comments:

Post a Comment