-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_methods_notes_starter.py
52 lines (33 loc) · 1.23 KB
/
list_methods_notes_starter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# List Methods Notes
# METHOD -
# Like strings and turtles, lists are objects that have their own special abilities,
# or list methods.
row = ["Ford", "Audi", "BMW", "Lexus", "Mercedes", "Jeep"]
print (row)
# 1: Append Method
# adds an element to the end of a list
#append multiple is a trap!
#row.append("Ford", "Buick")
#print (row)
# 2: Pop method
# removes an element by index value from a list and returns it
# try to... remove the first car in the row
# 3: Remove method
# removes the first occurence of an element from a list
# try to... remove the BMW
# 4: Sort method
# sorts a list in ascending order
# try to... sort the list in ascending order
# 5: Reverse method
# reverses the order of a list
# try to... sort the list in descending order
# 6: Count method
# counts the number of occurances of an element
# try to... count the number of "Ford" cars in the row
# 7: Index method
# displays the index value of an element
# try to... display the index value of the "Jeep"
# 8: Insert method
# inserts an element at a specific index value
# try to... insert a "Harley Davidson" in the second parking spot
input("Press enter to exit.")