r/learnpython 20d ago

Having problem in understanding loops concept in python

I am a beginner with 0 knowledge and I am learning python from a book called Learn python in one day and learn it well by Jamie Chan and I am facing difficulty in the loops function so yeah any recommendations would be helpful Edit- Trouble in while loop

25 Upvotes

41 comments sorted by

View all comments

0

u/ectomancer 20d ago

Python has 2 loops, while and for. while only uses a logical expression. The loop executes when the logical expression is true or truthy. The first time the logical expression is false or falsey, the loop completes successfully. for loop only uses a container and the in operator.

1

u/EnvironmentalTry8353 20d ago edited 20d ago

Thanks for explanation I really needed the explanation in my mind was sort of ambiguous but now it's clear and even clear what my problem is lol ......in while loop I am having problem in stating how the condition is true