Triangle Quest 2

  • + 0 comments

    n = int(input()) pyramid = []

    for i in range(1, n + 1): # build ascending and descending numbers line = list(range(1, i + 1)) + list(range(i - 1, 0, -1)) pyramid.append(''.join(map(str, line))) # we convert numbers to strings here once

    single print statement

    print(*pyramid, sep='\n')