Skip to content

Instantly share code, notes, and snippets.

@hoiogi
Last active May 16, 2018 06:54
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 hoiogi/a98beb9ef674300c84961328b57b9e71 to your computer and use it in GitHub Desktop.
Save hoiogi/a98beb9ef674300c84961328b57b9e71 to your computer and use it in GitHub Desktop.
def printPyramid(num):
data = list(range(1, num)) + list(range(num, 0, -1))
for i in data:
result = ' ' * (i-1)
if i == 1:
result += ''.join(str(x) for x in data)
else:
result += ''.join(str(x) for x in data[i-1:-i+1])
print(result)
printPyramid(5)
printPyramid(7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment