Python Exercise Example 33

Python 100例Python 100 Examples

Question:Separate a list with commas.

Program 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例Python 100 Examples

Other Extensions