Skip to content

Instantly share code, notes, and snippets.

@tiborsaas
Last active November 6, 2016 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiborsaas/ee778df126a441420678e2229f363c63 to your computer and use it in GitHub Desktop.
Save tiborsaas/ee778df126a441420678e2229f363c63 to your computer and use it in GitHub Desktop.
class Diamond():
def __init__(self, depth):
self.depth = depth
def draw(self):
self.triangle(self.depth//2, 'up')
self.triangle(self.depth//2, 'down')
def triangle(self, depth, direction):
if direction == 'up':
buildRange = range(1,depth)
else:
buildRange = range(depth,0,-1)
for line in buildRange:
padding = depth - line
print( ' ' * padding + '*' * ( line * 2 - 1 ) )
myDiamond = Diamond(11)
myDiamond.draw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment