Help me with this python puzzle | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help me with this python puzzle

I've this list as follows ['I', 'love', 'code', 'networking', 'Gaming' I need to join the list together without the single quotes and add a slash between the last 3 words

17th Mar 2021, 6:07 PM
Timm0x443
Timm0x443 - avatar
4 Answers
+ 4
string = ' '.join(list[:-3])+' '+'/'.join(list[-3:])
17th Mar 2021, 6:11 PM
visph
visph - avatar
+ 1
list[:-3] slice the list (get sublist) from start to third last item (not included) list[-3:] slice the list from third last item to end str.join() join the list passed as argument with the given string + concatenate strings
18th Mar 2021, 11:43 AM
visph
visph - avatar
17th Mar 2021, 6:08 PM
Timm0x443
Timm0x443 - avatar
0
visph worked very well. ThankYou. Could you break it down a little bit. I'm trying to understand it
18th Mar 2021, 11:40 AM
Timm0x443
Timm0x443 - avatar