Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Original post https://www.facebook.com/photo/?fbid=608157219018212&set=a.216079138226024
- # Pastebin thread https://pastebin.com/x4yk4gp7
- print("Corrected Code that should be in the post:\n\n")
- def print_diamond(rows):
- for i in range(1, rows + 1):
- print(" " * (rows - i) + "* " * (i))
- for i in range (rows -1,0,-1):
- print(" " * (rows - i) + "* " * (i))
- print_diamond(5)
- print('\n')
- def print_hollow_square(rows):
- for i in range (rows+1):
- if i == 0 or i == rows :
- print("* " * rows)
- else:
- print("* " + " " * (rows - 2) + "*")
- print_hollow_square(5)
- print('\n')
- def print_inverted_triangle(rows):
- for i in range (rows, 0, -1):
- print("* " * i)
- print_inverted_triangle(5)
- print("\n\n\nCode in the post:\n\n")
- def print_diamond(rows):
- for i in range(1, rows + 1):
- print(" " * (rows - i) + "*" * (2*i-1))
- for i in range (rows -1,0,-1):
- print(" " * (rows - i) + "*" * (2*i-4))
- print_diamond(5)
- print('\n')
- def print_hollow_square(rows):
- for i in range (rows+1):
- if i == 0 or i == rows :
- print("*" * rows)
- else:
- print("*" + " " * (rows - 2) + "*")
- print_hollow_square(5)
- print('\n')
- def print_inverted_triangle(rows):
- for i in range (rows, 0, -1):
- print("*" * i)
- print_inverted_triangle(5)
Advertisement
Add Comment
Please, Sign In to add comment