Why isn’t my * triangle code acceptable? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why isn’t my * triangle code acceptable?

It looks to me like I’ve solved the practice q but it’s not an acceptable answer, so I’m stuck. Please could someone give me a steer? https://code.sololearn.com/cTZqbc3Xs46x/?ref=app

18th Sep 2021, 4:17 PM
Sarah von Blumenthal
7 Answers
+ 3
You should only remove all the spaces. And i have a newline after the last four stars, i don't know if it will make a difference.
18th Sep 2021, 4:27 PM
Paul
Paul - avatar
+ 1
Paul, thank you - that worked. I had envisioned a different alignment for the triangle. Making it more complicated than it needed to be!
18th Sep 2021, 4:31 PM
Sarah von Blumenthal
0
You should use a loop to print the stars as a shape triangle, I think. Happy coding!
18th Sep 2021, 4:19 PM
mesarthim
mesarthim - avatar
0
I’m only on Lesson 8.1 and haven’t been introduced to loops yet, so I wonder if there’s another reason?
18th Sep 2021, 4:22 PM
Sarah von Blumenthal
0
print(" *\n * *\n * * *\n* * * *") Try this!
18th Sep 2021, 4:23 PM
Vadivelan
0
Sarah von Blumenthal I see, no problem. Just try to print all lines one by one. print("*") print("**") ... Happy coding!
18th Sep 2021, 4:25 PM
mesarthim
mesarthim - avatar
0
Thanks Vadivelan. I’m afraid it didn’t work. mesarthim I’ll try that, but the activity tip talked about using spaces and \n
18th Sep 2021, 4:27 PM
Sarah von Blumenthal