+ 5
Explain the working of this code.
Plz explain how 2nd line of this code work. https://code.sololearn.com/cIW7FVQTBehS/?ref=app
4 Réponses
+ 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'.
+ 4
I got it. Thx bro !!!
+ 3
Shashi Ranjan Thx a lot for help !!!
+ 1
make sure you get all of it!👍😁