Skip to content

Instantly share code, notes, and snippets.

@sakhayadeep
Created August 4, 2019 16:04
Show Gist options
  • Save sakhayadeep/c3e0058375ff75399edef02f00856f35 to your computer and use it in GitHub Desktop.
Save sakhayadeep/c3e0058375ff75399edef02f00856f35 to your computer and use it in GitHub Desktop.
horizontal number pyramid pattern
x = int(input())
arr = []
k = 1
for i in range(x):
for j in range(i+1):
arr.append(str(k))
k += 1
print(arr)
t = iter(arr)
arr2 = []
for i in range(x):
arr2.append(("*".join([next(t) for _ in range(i+1)])))
#arr2.append(("*".join(arr[:i+1])))
print(arr2)
for i in arr2:
print(i)
for i in arr2[::-1]:
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment