user2789945
user2789945

Reputation: 565

while loop (Python)

If I wanted to say something for a while loop such as: while time is greater than or equal to 0, would it simply be written as while time > or == 0? Or is there no way to do this?

Upvotes: 1

Views: 305

Answers (3)

user3103724
user3103724

Reputation: 1

Counting in Python example:

time = 0 
while time < 100: 
    time = time + 1 
    print time

Upvotes: 0

falsetru
falsetru

Reputation: 369424

Use while time >= 0 (equivalent to while time > 0 or time == 0)

>>> 0 >= 0
True
>>> 1 >= 0
True
>>> -1 >= 0
False

Upvotes: 6

Hyperboreus
Hyperboreus

Reputation: 32449

It would be:

while time >= 0:
    pass
    #here be dragons

Upvotes: 0

Related Questions