Click here to Skip to main content
15,887,328 members
Please Sign up or sign in to vote.
1.12/5 (5 votes)
See more:
a = int(input()) 
print("+ " * a) 

for i in range(1,a-1):
    space = "  " * (a - i - 2) 
    start = "  " * i 
    row  = start + "* " + space + "* " 
    print(row) 

print("  " * (a - 1) + "*")


What I have tried:

a = int(input()) 
print("+ " * a) 

for i in range(1,a-1):
    space = "  " * (a - i - 2) 
    start = "  " * i 
    row  = start + "* " + space + "* " 
    print(row) 

print("  " * (a - 1) + "*")
Posted
Updated 4-Jul-23 1:07am
Comments
Richard MacCutchan 4-Jul-23 6:48am    
Do you have a question?
Graeme_Grant 4-Jul-23 6:48am    
Yes, and what about this code? You need to hit the "Improve question" link and add words to explain what is happening, what you have tried, what the exact isue is and where. Remember, Telepathy is not real, and we cannot see your screen from here!

To quote the help in the yellow box where you post your question:

A few simple rules when posting your question.

1. Be courteous. Everyone here helps because they enjoy helping, not because it's their job.
2. Have you searched or Googled for a solution?
3. Be specific! eg "How do I change the dialog colour?" instead of "My code doesn't work. Help?"
4. Tag your question appropriately.
5. If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
6. Do not remove or empty a message if others have replied.
7. Your question may be edited or retagged by others. Anything inappropriate will be removed.
CPallini 4-Jul-23 6:58am    
Yes, it is.

1 solution

And if I run your code, I get what appears to be a "Hollow right angle triangle":
Results
5
+ + + + + 
  *     * 
    *   * 
      * * 
        *
Unfortunately, we have no idea what your assignment is, or how this differs from the output you need to get in order to hand this in.

As such, I suspect that you have just found code that does something similar to your teacher's requirement and want us to "fix it" so it matches.

We can't do that as we have no idea what is required; but we wouldn't do it all for you if we did: we are not here to do your homework for you as you would learn nothing from the exercise!

Give it a try and write your own code - it's easier than you think!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900