Lesson 38

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 : )

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s