+ 1

Python list Problem

I want to print objects of the list in one line For example i have the list [1 , 2 , 3] I want to print it like this: 1 ,2 ,3 Pleas help!!!!

30th May 2019, 7:43 AM
Mohammad Hadi Hedayati
Mohammad Hadi Hedayati - avatar
3 Answers
+ 4
You can use the for loop to print it. list=[1,2,3] for i in list: print(i,end=' , ') Thanks
30th May 2019, 7:46 AM
Prince PS[Not_Active]
Prince PS[Not_Active] - avatar
+ 3
Like Jay Matthews said, you could also do it like this: ', '.join(list) Keep in mind that all the items in the list have to be strings or you will get an error
30th May 2019, 2:09 PM
Trigger
Trigger - avatar
0
thanks!!!
30th May 2019, 9:44 PM
Mohammad Hadi Hedayati
Mohammad Hadi Hedayati - avatar