Home > Net >  How to output this template in Python3
How to output this template in Python3

Time:06-25

How to output this template in Python

Can this be done with the for loop? Help friends thanks

enter image description here

CodePudding user response:

How to output this template in for loop in Python

enter image description here

CodePudding user response:

rows = 9
for i in range(1, rows):
    for i in range(0, i, 1):
        print(format(2 ** i, "4d"), end=' ')
    for i in range(-1   i, -1, -1):
        print(format(2 ** i, "4d"), end=' ')
    print("")
  • Related