Katemonkey (In Most Places)

Learning Python, Day 5 — "The List Ninja"

Okay, Friday was a total wash, and the weekend was the weekend, but I am back and ready for lists!

07 — The List Ninja

I do like lists. It's the only way I manage to keep track of everything. So when you tell me how to make lists of things in Python, I am pleased. Mmmm. Lists. I'm categorising things. I'm in heaven.

However, "List Ninja"? No. Unless I'm secretly making lists for the daimyō who has hired me, I am not a list ninja. I am a list person (job title irrelevant).

And these "Ninja Traits"? What.

ninjaTraits = [ "silent", "sneaky",
                "patient", "humble",
                "strong" ]

Remembering that 0 is the first item in a list though is going to bug me, though. But that is because I am pedantic.

In fact, one of my lists made that very clear.

mytraits = ["smart", "boring", "pedantic"]
othertraits = ["dumb", "interesting", "pedantic"]
mytraits == othertraits

>> False

And remembering that if I want the full range to appear, I have to add one extra number in my range (using 1:3 when I want items 1 to 2). But I figure this is all something that will happen over time and it'll become second nature to me, like what c1b means in knitting or what bb.MoveObjects on does in Sims 4.

(Yeah, I know there's integer: to give me all the items to the end of the list, but I'm talking about, like, :integer and integer:integer. So annoying.)

I also like checking if an item is in a list, but the test examples are boring. I'm not going to check if I've written the right colours. Or the right shapes. Or whatever.

hipdirectors = ["John Waters",
                "David Lynch",
                "David Cronenberg",
                "Brandon Cronenberg",
                "Ryan Coogler",
                "Guillermo del Toro"]
"Brett Ratner" in hipdirectors

>> False

Yeah, buddy, you're never in the hipdirectors list.

I'll also have to remember that when I add an item to the list, that it won't return a result unless I print() the list. As much as I love Rose Glass's films, she doesn't need to be in the hipdirectors list twice.

But I can remove them in a variety of ways, so if I accidentally put Rose Glass in, like, 20 times, I can just del hipdirectors[8:] and it'll get rid of all but one of her.

Day 5 — Results

Tomorrow, it's time for if statements. Oh, I am going to keep my hipdirectors list going and give you all terrrrrrible opinions.

Today's Sticker

An illustration of David Lynch, with a flower garland along the bottom.

Floral David Lynch from Megomobile.

#kate learns python #programming