Python: list the list elements in several cases output

1. counterparts output

. 1 List = [. 1, 2,. 3,. 4 ]
 2  # output element separated by commas 
. 3  for I in List:
 . 4      Print (I, End = ' , ' )
 . 5  # output elements separated by spaces (Note: The last there is still space) after the element 
. 6  for J in List:
 . 7      Print (J, End = '  ' )
 . 8  # output elements separated by spaces (note: no space after the last element) 
. 9  Print ( "  " .join (STR ( the X-) for the X- in List))

2. Different line output

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

Guess you like

Origin www.cnblogs.com/xiaolan-Lin/p/12241864.html