0

I am trying to make all numbers right-aligned, here is my code:

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()
Isma
  • 14,604
  • 5
  • 37
  • 51
Maria
  • 1
  • 3
  • 1
    Can you explain what do you mean by right-aligned? Your code is just printing some numbers in the command window, I don't think you can right-align there. – Isma Nov 13 '17 at 10:15
  • Assuming this prints into a console, what does it even mean to "right align" numbers? To some other text? To the edge of the console screen? – M. Prokhorov Nov 13 '17 at 10:25
  • all numbers in rows should be right aligned – Maria Nov 13 '17 at 10:31
  • my task is - write code that will input two positive integers r and c and display a table with r rows and c columns, where the value of the mth number in the nth row is n^m – Maria Nov 13 '17 at 10:37

0 Answers0