Python (access element in list and print with string) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python (access element in list and print with string)

hi=[21,23,24,25] print ("list contains"+str(*hi,sep=" , ") The above code is correct to print elements in list with string and with out square bracket I need output like O/p : List contains 21,23,24,25 Please help

17th Aug 2019, 2:08 AM
ASHARAF K
ASHARAF K - avatar
3 Answers
+ 4
hi=[21,23,24,25] print (','.join([str(x) for x in hi]))
17th Aug 2019, 2:15 AM
Hatsy Rei
Hatsy Rei - avatar
0
I want to print it with some string
17th Aug 2019, 2:17 AM
ASHARAF K
ASHARAF K - avatar
17th Aug 2019, 8:49 AM
Sarvesh Yadav
Sarvesh Yadav - avatar