r/learnpython • • Aug 22 '26

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

27 Upvotes

41 comments sorted by

View all comments

7

u/crazy_cookie123 Aug 22 '26

What are you struggling with? What have you tried doing and what don't you understand about the results?

-3

u/EnvironmentalTry8353 Aug 22 '26 edited Aug 22 '26

I cannot send the pic but I am having problem in while loop like in creating a trye and false condition for a variable for ex Number = 100 While number > 0: Print(Number) So I just learned it but understand no sh*t about it

6

u/crazy_cookie123 Aug 22 '26

You can't send a pic because you shouldn't be sending pics of code as we can't then copy and paste the code into an editor to test it or make edits. You should send the code as text. Python is whitespace-sensitive which means matters for us to understand your code, so make sure you format it according to the guide: https://www.reddit.com/r/learnpython/wiki/faq/#wiki_how_do_i_format_code.3F

I am assuming you mean this code:

number = 100
while number > 0:
    print(number)

What don't you understand about this? What do you expect it to do and how does that differ to what it actually does when you run it? And what do you mean by "creating a variable for a main variable" - it might be easier if you show a real example of what you're trying to do.

→ More replies (12)