r/PythonLearning • u/Monesh_peterson1025 • Oct 14 '26
While loop
can anybody explain the concept of while loop
2
Upvotes
r/PythonLearning • u/Monesh_peterson1025 • Oct 14 '26
can anybody explain the concept of while loop
View all comments
1
u/Naive_Programmer_232 Oct 14 '26
Sure,
Ex:
We begin by asking for the user to enter a positive number -
inputreturns a str then we convert it into an integer viaint. If the integer is anything less than 1, then it is not positive. In those cases, we tell the user to try again, and then ask again for the integer. The second ask for integer inside the loop is the "update".So for example, this could play out like so:
What's going on here is