Python Python Basics All Together Now Branch and Loop

Juan Llano
Juan Llano
Full Stack JavaScript Techdegree Student 481 Points

WHILE LOOP QUESTION

Towards the end of the video, why does Craig put while tickets_remaining >=1: instead of putting while tickets_remaining >0:? Thank you in advance.

2 Answers

Steven Parker
Steven Parker
172,266 Points

The functionality would be identical with either code choice. There will often be more than one valid way to code something, and it's "programmer's choice". He may have chosen that intentionally because he felt it conveyed the purpose of the code better, or it might just have been the first thing he thought of.

Perhaps if we tag him here, Craig Dennis will drop by and let us know!

Luke Maschoff
Luke Maschoff
820 Points

To add on to Steven, in a programmers view, it seems much nicer to say, "greater than, or equal to 1" over saying, "greater than 0". It makes the code much easier to read, edit, and maintain.