0

is there a way to omit automatic \n after 'print' in python 3.x?
i want my output something like this:-

2 2
2 4
4 8
8 32

my code is like this:-

a,b=1,2
while b<10:
    print (str(b)+' '+str(b*a))
    a,b=b,b*a

but i want my code to be like this to print the same thing:-

a,b=1,2
while b<10:
    print (str(b))
    a,b=b,b*a
    print (str(b))

but its printing this:-

2
2
2
4
4
8
8
32

please help me out i am a newcomer in programming and python is my first language.
Thank you!

1 Answers1

-1

print (str(b)+' '+str(b*a), end="\n")

Corrected statement as per comment.

spatel
  • 460
  • 3
  • 8
  • with your print statement, "2 22 44 88 32" will get printed. I believe you meant to respond with print (str(b)+' '+str(b*a), end="\n")! :0) – Devarsh Desai Jun 24 '14 at 01:03