Question

Hello I would like to ask how to write a python program which looks like this...

Hello

I would like to ask how to write a python program which looks like this

    |
  | * |
| * | * | 
| * | * | 
  | * |
    |

The input for this program is 3, the user would input the number and it would print accordingly

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#take input
n=int(input())
#print "|" the nummber of whitespace will be n-1
print(" "*(n-1),"|")
#print sequence of "|*|" ,number of whitespace will be n-i
for i in range(2,n+1):
   print(" "*(n-i),"|*|"*(i-1))
#repeat the above process in reverse order
for i in range(n,1,-1):
   print(" "*(n-i),"|*|"*(i-1))
print(" "*(n-1),"|")

Add a comment
Know the answer?
Add Answer to:
Hello I would like to ask how to write a python program which looks like this...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT