Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
while loop
#1
I want to write a program that gives the following outputs with the Python while loop.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
I can't find a way how to do it.
Reply
#2
what have you tried so far?
Reply
#3
(Dec-16-2020, 12:07 PM)Larz60+ Wrote: what have you tried so far?
a=1
while(True):
    a+=1
    print(a)
    break
I know this is not the correct answer. But how should I write here so that I can find the correct answer.
Larz60+ write Dec-16-2020, 06:35 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Fixed for you this time. Please use bbcode tags on future posts.
Reply
#4
First write the steps out in English. Then try coding each step. Think about how you would use loops to accomplish your task.
ndc85430 likes this post
Reply


Forum Jump:

User Panel Messages

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