Abraxas
  • Abraxas
Who knows how to print in a single line the result of a for loop statement in Python3? In Python 2 we can print the content of a list in a unique line like this: >>> A = list(range(3)) >>> A [0, 1, 2] >>> for i in A: print i 0 1 2 >>> for i in A: print i, 0 1 2 ## but if we try to print the same function in ## Python3 it displays another thing >>> for i in A: print (i), 0 (None,) 1 (None,) 2 (None,) ## Thank a lot for your help!!!
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
andrew.m.higgs
  • andrew.m.higgs
Try print (i,) I dont have Python 3 but the doc looks as though this should work. Hope this helps.
Abraxas
  • Abraxas
Nop. it doesn't work either. :( Thank anyway!
Abraxas
  • Abraxas
The help only says: print( . . . ) print(value, ..., sep=' ', end='/n', file=sys.stdout) optional keyword arguments: file: ..bla bla bla.. sep: string inserted between values, default a space. end: string appended after the last velue, default a new line. I tested with both but nothing. : (

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

andrew.m.higgs
  • andrew.m.higgs
l = (1, 2, 3, 4, 5) for i in l: print (i, end=' ')
andrew.m.higgs
  • andrew.m.higgs
The default value for end is a new line char. Replace it with a space and you get the result you want.
Abraxas
  • Abraxas
Sí!!!!!!!! Gracias!!!!!
andrew.m.higgs
  • andrew.m.higgs
:-) Glad I could help.

Looking for something else?

Not the answer you are looking for? Search for more explanations.