Generation

generate functionSat, 03 Dec 2022

Pattern generator: 1 1 2 2 3 3 4 4 5 4 4 3 3 2 2 1 1

def pattern(n): for i in range(n): for j in range(n): if j <= i: print(j+1, end="") else: print(" ", end="") for k in range(n-1, -1, -1): if k <= i: print(" ", end="") else: print(k+1, end="") print() pattern(5)

Questions about programming?Chat with your personal AI assistant