-2

Screenshot of code and output

Code

num = int(input("Enter the number of rows:"))
for i in range(0,num):
  for j in range(0,num-i-1):
    print(end="")
  for j in range(0,i+1):
    print("*",end="")
  print()

Current output

*
**
***
****
*****
******
    

answer is not exactly the same as PYRAMID, show it in the picture

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
md Tanvir
  • 13
  • 2
  • What your expected output. Which output do you get? We do not see your pictures. Please [edit]. `print(end="")` does nothing btw. so your whole 1st `j` loop is superflous – Patrick Artner Aug 27 '20 at 11:50
  • I add a picture so it's show me in the left side rather than in the middle – md Tanvir Aug 27 '20 at 11:58
  • 1
    Please show the output as text, not as a (bad) image. At least make a proper screenshot. – mkrieger1 Aug 27 '20 at 12:01
  • Look, mkrieger1 1 actually i am having problem with screenshot in windows8.1 perhaps my windows need new windows, please answer my question from this picture , i am really sorry that i can't complete your requirement and i am a new user help me please – md Tanvir Aug 27 '20 at 12:15

1 Answers1

0

I think you want your pyramid to be centered and not leaning to the left side. For that, you have to adjust the spacing before and after the stars in your loops accordingly:

Changed Code

num = int(input("Enter the number of rows:"))
for i in range(0,num):
  for j in range(0,num-i-1):
    print(end=" ")
  for j in range(0,i+1):
    print("*",end=" ")
  print()

Output

     * 
    * * 
   * * * 
  * * * * 
 * * * * * 
* * * * * * 
Kim Tang
  • 2,330
  • 2
  • 9
  • 34
  • 1
    Kim Tang thank you so much bro i am really really appreciate ur work and its certainly works and GOD bless u and i will pray for u too dude :) – md Tanvir Aug 27 '20 at 12:26
  • I'm glad I could help! It would also be nice if you could mark my answer as being "accepted" with the green checkmark. Thank you! – Kim Tang Aug 27 '20 at 12:28