+ 1

Triangle of stars

Hi I’m stuck with this question please help me : This code tries to make a triangle out of stars. But oh no! There’s an error in there somewhere - it outputs all the stars on one line, instead of separate lines. Fix the code to output a triangle of stars that has 4 rows. https://code.sololearn.com/cqnZdycFwOmt/?ref=app

21st Aug 2021, 9:22 AM
Gaswindoo
7 ответов
+ 3
You need to remove the extra "\n" to avoid it. print("*\n**\n***\n****")
21st Aug 2021, 11:33 AM
Simba
Simba - avatar
+ 4
for x in range(15): print(' '*(15-x)+'*'*x+'*'*x+'*') https://code.sololearn.com/cuiP99YX3cKW/?ref=app
21st Aug 2021, 11:10 AM
SAN
SAN - avatar
+ 2
x = 5 for i in range(1, x+1): print("*"*i)
21st Aug 2021, 12:36 PM
Shadoff
Shadoff - avatar
+ 1
print("*\n**\n***\n****\n")
1st Feb 2022, 4:31 AM
KESHAV KONDABALA
KESHAV KONDABALA - avatar
+ 1
you can try this code below print("""* ** *** ****""")
10th Jun 2022, 10:16 PM
Ellyjah
Ellyjah - avatar
0
Thx!
21st Aug 2021, 11:26 AM
Gaswindoo
0
print("*\n**\n***\n****\n")
19th Dec 2021, 8:02 AM
Tewodros Worku