I have this code where given an integer n, I want to print out all integers in the interval [1→n] that divide n, separated with spaces. I wrote this code:
n = int(input('Enter number:'))
for i in range(1, n+1):
if (n%i==0):
print (i)
I get this as the answer:
Enter number:8 1 2 4 8
But I want my answer next to each other, separated using spaces (so: 1 2 4 8
). How do I do this?