我正在尝试使所有数字右对齐,这是我的代码:
r=int(input('How many rows do you want?'))
while r<=0 :
print('This value is not suitable')
r=int(input('How many rows do you want?'))
c=int(input('How many columns do you want?'))
while c<=0 :
print('This value is not suitable')
c=int(input('How many columns do you want?'))
largest = (len(str(r**c)))
for i in range(1, r+1):
for y in range(1, c+1):
number = i**y
tarp = ' ' * ((largest - len(str(number))))
print(number, end = tarp)
print()