0

Here is my code

list = [1,2,3]
for i in list:
    print(i)

This is the output

1
2
3

What I'm looking for

1, 2, 3
ThePyGuy
  • 13,387
  • 4
  • 15
  • 42
Cristian
  • 145
  • 5

2 Answers2

0

If python 3 print(i, end =", ")

If python 2 append a comma to the print to escape the newline print(i),

Enigma
  • 372
  • 1
  • 10
0

A mixture of generators and join

lst = [1,2,3]
print(','.join(str(i) for i in lst))
OneCricketeer
  • 151,199
  • 17
  • 111
  • 216
Thavas Antonio
  • 5,542
  • 1
  • 11
  • 33