Last active
December 16, 2015 15:09
-
-
Save chrishoffman/5453822 to your computer and use it in GitHub Desktop.
Diamonds and stars
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
def draw_line(number_of_stars, width): | |
spaces = (width - number_of_stars) / 2 | |
print ' ' * spaces + '*' * number_of_stars | |
def diamond(number): | |
for i in xrange(1, number, 2): | |
draw_line(i, number) | |
for i in xrange(number, 0, -2): | |
draw_line(i, number) | |
diamond(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment