Python Exercise Example 33
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,5Other Extensions
Python 100 Examples