cc hui3,030 Points
branch and loop exercise on tickets_remaining count down while loop
On the branch and loop exercise, Craig uses tickets_remaining >= 1 for the countdown while loop, but I use while tickets_remaining > 0 instead and it works the same. So, can I say both are correct answers? I appreciate any comment.
Based on this exercise, there should be no problem in using
> 0, so yes it fine to use it. Also, the code limits the user from inputting stuff like
0.12, if the user tries it, the error would be caught by
num_tickets = int(num_tickets) because it only accepts integers and not floats. I don't see any errors.
However, it is best practice to state exactly what you want your code to do and it follows convention. the ZEN of python states " Explicit is better than implicit"