Python Forum
Print triangle using while loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print triangle using while loop
#1
The following code will print a triangle of stars.
How we can obtain the same result using while loop? And explain how it works?
Thanks in advance for any help?

l=int(input("Enter the limit:"))
for i in range(1,l+1):
    for j in range(i):
        print("*",end="")
print()
TuxAndrew
Linux - RedHat,cPANEL CentOS,Ubuntu,Azure/AWS Administrator,
Assistance, Analysis and Diagnosis. Skype: tuxandrew,

[email protected]
Reply


Messages In This Thread
Print triangle using while loop - by tuxandrew - Dec-04-2019, 04:20 PM
RE: Print triangle using while loop - by ichabod801 - Dec-04-2019, 06:15 PM
RE: Print triangle using while loop - by sumana - Dec-05-2019, 10:31 AM
RE: Print triangle using while loop - by micseydel - Dec-05-2019, 07:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to write a recursion syntax for Sierpinski triangle using numpy? Bolzano 2 4,024 Apr-03-2021, 06:11 AM
Last Post: SheeppOSU
  Print user input into triangle djtjhokie 1 2,523 Nov-07-2020, 07:01 PM
Last Post: buran
  Tkinter - The Reuleaux Triangle andrewapk 1 2,078 Oct-06-2020, 09:01 PM
Last Post: deanhystad
  Python - networkx - Triangle inequality - Graph Nick_A 0 2,197 Sep-11-2020, 04:29 PM
Last Post: Nick_A
  Help with for-loop printing. I want it to print only once. blacklight 2 7,192 Jun-26-2020, 02:23 AM
Last Post: pyzyx3qwerty
  Triangle function program m8jorp8yne 2 9,083 Dec-13-2019, 05:24 PM
Last Post: Clunk_Head
  Intersection of a triangle and a circle Gira 3 3,767 May-19-2019, 06:04 PM
Last Post: heiner55
  Program that, inside a loop, does multiple things. needs to print in a certain way reidmcleod 1 2,785 Feb-19-2019, 02:35 PM
Last Post: marienbad
  Draw isosceles triangle fen1c5 4 13,230 Jul-07-2018, 10:20 AM
Last Post: fen1c5
  Pascal's triangle nvakada 5 4,807 May-01-2018, 02:44 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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