Last active
October 31, 2018 21:58
-
-
Save RouNNdeL/83d42f7558c779357809837fb20d12fa to your computer and use it in GitHub Desktop.
Diamond in Python
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 diamond(n): | |
half = n/2 | |
print(half * " " + "*") | |
r = range(1, half + n % 2)+range(half-1, 0, -1) | |
for i in r: | |
print((half - i) * " " + "*" + (2*i-1) * " " + "*") | |
print(half * " " + "*") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment