Python Forum
beginner and need help with python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
beginner and need help with python
#3
Maybe this will help.

while-loop (while loop executes until condition becomes False)

n = 5                  # initial value

while 0 <= n:          # while value is greater or even 0
    print(n)           # print value
    n -= 1             # decrease value by one, go back to row #3 (loop)
Output:
5 4 3 2 1 0
for-loop (for loop executes until exhausted):

for i in range(5, -1, -1):      # range from 5 to -1 (excluded) incremented by -1 on every step
    print(i)
Output:
5 4 3 2 1 0
Python interactive interpreter has built-in help. At first it may seem too intimidating but if you really want to learn programming you should get acquainted with terminology and style of help. Just type >>> help('for'), >>> help('while'), >>> help(range) (press Q to exit the help)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
beginner and need help with python - by Tjay - Oct-13-2019, 07:35 PM
RE: beginner and need help with python - by perfringo - Oct-14-2019, 05:34 AM
RE: beginner and need help with python - by buran - Oct-14-2019, 05:54 AM
RE: beginner and need help with python - by Tjay - Oct-14-2019, 05:44 PM
RE: beginner and need help with python - by Tjay - Oct-14-2019, 07:06 PM
RE: beginner and need help with python - by Tjay - Oct-14-2019, 07:23 PM
RE: beginner and need help with python - by buran - Oct-14-2019, 07:37 PM
RE: beginner and need help with python - by Tjay - Oct-14-2019, 07:50 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020