Python Mario again!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a mario pyramid in python! | |
from cs50 import get_int | |
def main(): | |
# Prompt user for a positive number | |
while True: | |
n = get_int("enter a positive number: ") | |
if n > 0: | |
break | |
# Print out this many rows | |
for i in range(n): | |
# Print out this many columns | |
for j in range(n-(i+1)): | |
print(" ", end="") | |
for k in range(i+1): | |
print("#", end="") | |
print(" ", end="") | |
for l in range(i+1): | |
print("#", end="") | |
print() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment