python: printing horizontally rather than current default printing

前端 未结 10 2072
孤城傲影
孤城傲影 2021-02-05 06:32

I was wondering if we can print like row-wise in python.

Basically I have a loop which might go on million times and I am printing out some strategic counts in that loop

10条回答
  •  别那么骄傲
    2021-02-05 06:59

    a=int(input("RangeFinal "))
    print("Prime Numbers in the range")
    for n in range(2, a):
       p=0
       for x in range(2, n):
            if n % x == 0:
                    break
            else:
               if(p==0):
                  print(n,end=' ')
                  p=1
    

    Answer

    RangeFinal 19
    Prime Numbers in the range
    3 5 7 9 11 13 15 17 
    

提交回复
热议问题