In this exercise, we play with splitting, adding to lists, & the join function, referred to in this stack overflow post as the inverse of the split function.
split
cuts up any old text string, like mary had a little lamb
and turns it into a formal list, like ["mary", "had", "a", "little", "lamb"]
, with each word made into an indexable (numerically anyway) item in a list, via the format of stringofwords.split(" ")
. I’m not toooootally square on the quotes in the formatting of the use of split
, but I can punch it in well enough til I grok it fully.
join
depends on the same structure of listofitems.join(" ")
to de-string-ify it. Handy!
There’s a bit also with, hmm, how do you call it, positional list comprehension, maybe? For example in the previous given list, the ["mary", "had", "a", "little"}
et cetera, position 0
is the very first one, mary
, where position -1
is the very last, little
.
This was a good one! I think the exercises will stay challenging through the next thirteen : )