bocajbee

mario.py

May 31st, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. # get user input
  2. user_input = -1 # initally set input to == a value of -1
  3. while user_input < 0 or user_input > 10: # run this while loop forever until the users input is > 0 or < 10
  4.     user_input = int(input("Please enter pyramid height? ")) # get users input
  5.  
  6. for i in range(1, user_input + 1): # nested outer forloop needed incrementing i up to the users input in order to build the spaces before the pyramid + pyramid itself
  7.     print(" "*(user_input-i), end="") # print the spaces before the pyramid by using input-i everytime i increments
  8.     print("#"*(i),end="") # build left alligned pyramid
  9.     print(" ", end="") # build space between two pyramids
  10.     print("#"*(i)) # build second right alligned pyramid
Advertisement
Add Comment
Please, Sign In to add comment