Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Exercise Example 33

Python Exercise Example 33

Python 100 Examples Python 100 Examples

**Question:** Separate a list by commas.

**Analysis:** None.

Example (Python 2.0+)

#!/usr/bin/python

-- coding: UTF-8 --

L

=

[

1

,

2

,

3

,

4

,

5

]

s1

=

'

,

'

.

join

(

str

(

n

)

for

n

in

L

)

print

(

s1

)

The output of the above example is:


1,2,3,4,5

Python 100 Examples Python 100 Examples