+ 5

Explain the working of this code.

Plz explain how 2nd line of this code work. https://code.sololearn.com/cIW7FVQTBehS/?ref=app

29th Oct 2018, 12:33 AM
Arushi Singhania
Arushi Singhania - avatar
4 Answers
+ 6
"split()" method splits a given string whenever it finds a match for the given string. In this case, you've split(" ") means it'll split the string whenever it'll find a space and it'll return a list ['Emily', 'Kathie']. "string[start :end]" this method is used to slice the string from index 'start' to index 'end-1'. [:1] ==[0:1] and will take out the 0 index of the string i.e. 'E' from Emily and 'K' from Kathie. "join()" method takes a list of 'str' types as argument and join them by keeping in between whatever you want. ex. ','.join(list) will join the elements of the list with a comma in between. In your case, it's ''.join(list) so it'll join elements with keeping in between nothing. So, it'll create a string from 'E' and 'K' with nothing in between as 'EK'.
29th Oct 2018, 2:36 AM
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½ - avatar
+ 4
I got it. Thx bro !!!
29th Oct 2018, 3:36 PM
Arushi Singhania
Arushi Singhania - avatar
+ 3
Shashi Ranjan Thx a lot for help !!!
29th Oct 2018, 3:33 PM
Arushi Singhania
Arushi Singhania - avatar
+ 1
make sure you get all of it!šŸ‘šŸ˜
29th Oct 2018, 3:35 PM
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½ - avatar