Hi, everyone, welcome back - I'm getting busier with school and whatnot nowadays and can't spend as much time writing these lesson notes, so I'll leave them kind of barren for now and so just reach out to me if you need specifications -Bonnie
While Review Homework Review Lists
Homework - Questions 3 and 6 *Need to use list methods like .append() (adding to the end of list), .insert() (adding to a specific location of list), .pop() (removes from list), .sort() (sorts list by smallest to largest)
REVIEW OF WHILE LOOPS
LISTS
Indices - lists are a collection of variables in a single "basket" - each can be changed individually by referencing their location in the list (index) and is their own complete variable, acts like any other regular variable.
list = ["abc", "def", "ghi", 12, 5]
0 1 2 3 4
^Lists use square brackets [] and are given a name and a value (declared/instantiated) just like other variables, with the name and then an equal sign
^Indices are assigned starting from 0, increase 1 each time
print(list[1]) sum = list[3] + list[4]
print(list[0]) print(list[2 - 1]) list[1] = "hi" print(sum)
----------------- --------------------- print(list[1]) -----------------------------
"abc" "def" --------------------- 17
"def"
"hi"
list.split(separator) - separates a string into a list, separated by spaces by default but you can choose any character
message = "hello my name is Bonnie" message = "3.12313.eoiwjf.129" message.split() message.split(".") print(message) print(message)
---------------------------------------- ------------------------------------------------
["hello", "my", "name", "is", "Bonnie"] ["3", "12313", "eoiwjf", "129"]
Ask me any questions any time
See you guys next week :) -Bonnie (and Alan)