0

I want the answers to come out side by side, not on top of each other. How do I do that?

n=0

while 1:

    n=int(input("Enter N="))
    if n > 0:
             break
    print("Error. please enter only positive numbers.")
i=1
print("\nThe divisors of N are:",)
while i <=n:
    if (n%i) == 0:
        print(i,)
    i+=1
4

2 回答 2

9

换行

        print(i,)

        print(i, end=" ")
于 2012-09-21T14:54:21.233 回答
1

使用sys.stdout.write代替print

于 2012-09-21T14:53:47.933 回答