« All Events
7PM – Intro To Python – Joshua
October 10 @ 7:00 pm - 8:00 pm
Today We Did
- Review How to write a list: name_of_list = [ 0, “string”, “string2”]
- How to add things to list
- Way 1: Appending -> name_of_list.append(new_object)
- Way 2 : Inserting -> name_of_list.insert( 1, new_object)
- How To replace things in lists
- name_of_list[1] = new_object
- How to Delete things
- Way 1: Delete – >del name_of_list[0]
- Way 2 Pop -> x = name_of_list.pop()
- If you want to pop a specific, put its location within the parentheses Ex. .pop(1)
- Popping is good if you need to use it later
- Way 3: remove -> name_of_list.remove(“string”)
- Allows you to remove the first instance of it
- Useful if you know the object/data/string but not Where it is
Homework
- Label this October_10_list_hw2.py
- 3rd edition: TRY IT YOURSELF from page 41-42: 3-4, 3-5, 3-6
- Remember to put it in your drive