How can I modify the syntax end=' ' to print on the next line of while loops?
I'm writing a simple code to print the factor of a number from the user input. However, the next line of user input starts on the same line as the indexes of previous loop.
while True:
num = int(input('enter a number: '))
print('factor of {}: '.format(num), end = ' ')
for i in range (1,num+1) :
if num%i == 0 :
print(i, end = ' ')
Output:
enter a number: 32
factor of 32: 1 2 4 8 16 32 enter a number: 32
factor of 32: 1 2 4 8 16 32 enter a number: 32
factor of 32: 1 2 4 8 16 32