+ 1
What does .split do?
s1=‘It\’s cool to earn money’ s2=s1.split What is the result of this?
4 odpowiedzi
+ 8
Provided that those will be single quotes and not gravises, the command:
puts s2
should split the string and print out each word in a separate line:
It's
cool
to
earn
money
while:
print s2
prints a list, with each of the words as elements:
["It's", "cool", "to", "earn", "money"]
+ 6
Shortly speaking - it transforms a string into a list of its separated (split) elements.
0
I kinda don’t get it. Could you please enter the result?
0
Oh ok I think I get it now thanks