I'm so bad at math | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

I'm so bad at math

Fix the code to output a triangle of stars that has 4 rows

18th Sep 2021, 8:43 AM
Patrick Fernandez
22 Answers
+ 10
So...and that was math?
18th Sep 2021, 8:06 PM
Oma Falk
Oma Falk - avatar
+ 9
Patrick Fernandez "Why do we need to remove those spaces" Spaces to the human mind is a gap between text that allows us to identify words in a sentence. So we tend to ignore it. But a space to a computer is a text character, just as important as a letter, number or punctuation mark. Just because we can't see it does not mean it doesn't exist. Let me attach a little code which may help you understand further https://code.sololearn.com/cR8q6PcSDb0A/?ref=app
18th Sep 2021, 9:35 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Patrick Fernandez , please post the task description and the code you have done so far. thanks!
18th Sep 2021, 8:46 AM
Lothar
Lothar - avatar
+ 2
Remove the extra spaces. And your code outputs 5 lines.
18th Sep 2021, 8:56 AM
Arsalan [Inactive]
Arsalan [Inactive] - avatar
+ 2
Anything can be improved through practice
18th Sep 2021, 10:47 PM
Sonic
Sonic - avatar
+ 2
I'm bad at math too so ur good!! XD
19th Sep 2021, 6:51 AM
Mya Cook
+ 1
Just for passing the sololearn test.
18th Sep 2021, 8:59 AM
Arsalan [Inactive]
Arsalan [Inactive] - avatar
0
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. Sol. Print("* \n** n\*** n\**** n\****")
18th Sep 2021, 8:49 AM
Patrick Fernandez
0
I mean Print("* \n** \n*** \n**** \n*****")
18th Sep 2021, 8:51 AM
Patrick Fernandez
0
And my answer is wrong
18th Sep 2021, 8:52 AM
Patrick Fernandez
0
I've got the answer sir thank you. Btw why do we need to remove those spaces sir?
18th Sep 2021, 8:58 AM
Patrick Fernandez
0
HAHAHA
18th Sep 2021, 9:00 AM
Patrick Fernandez
0
Thanks man 👌
18th Sep 2021, 2:13 PM
Patrick Fernandez
0
Try and learn code anytime, anywhere
19th Sep 2021, 7:42 AM
Hydrogen Man
0
Patrick Fernandez print(" * \n *** \n ***** \n******* "); U can try this. And also try this to get triangle. https://code.sololearn.com/cj7vngi7L13Q/?ref=app
19th Sep 2021, 10:44 AM
Ansheeta
Ansheeta - avatar
0
For any size of rows, you need to start from 1 and add one * to reach the defined size.
19th Sep 2021, 11:04 AM
kiarash Yavari
kiarash Yavari - avatar
0
for _ in range(1, 5): print('*'*_)
19th Sep 2021, 11:08 AM
Lior Zizi
Lior Zizi - avatar
0
for counter in range(1:row_numbers+1): stars = counter for star in range(stars): print(* +'\n') Like this if I'm not mistaken
19th Sep 2021, 11:21 AM
kiarash Yavari
kiarash Yavari - avatar
0
kiarash Yavari not efficent
19th Sep 2021, 11:24 AM
Lior Zizi
Lior Zizi - avatar
0
Efficient is the next level for new learners😉
19th Sep 2021, 11:28 AM
kiarash Yavari
kiarash Yavari - avatar