Python 33
[Python 100] Python 100
(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)
1,2,3,4,5
[Python 100] Python 100
| [ Web Proxy ] |
| Viewing: https://www.runoob.com/python/python-exercise-example33.html | [Back] [Original] |
[Python 100] Python 100
1,2,3,4,5
[Python 100] Python 100
| Web Proxy Viewer | New URL | Original Page |
129***[email protected]
129***[email protected]
Webben
wei***[email protected]
# -*- coding: UTF-8 -*- l = [1,2,3,4,5,6,7]; k = 1; for i in l: print(i,end= ('' if (k == len(l)) else ',')); k += 1;Webben
wei***[email protected]
Webben
wei***[email protected]
#!/usr/bin/python3 l = [1,2,3,4,5,6,7]; o = ''; for i in l: o += str(i)+','; print(o[0:-1]);Webben
wei***[email protected]
374***[email protected]
Python3
a=[1,2,3,4] for i in range(0,len(a)): if i!=(len(a)-1): print(a[i],end=',') else: print(a[i])374***[email protected]
239***[email protected]
Python3
numbers=list(range(1,9)) for i in numbers: if(i==numbers[-1]): print(i) else: print(i,end=',')239***[email protected]
ren***[email protected]
ren***[email protected]