-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReviewLists.py
More file actions
66 lines (40 loc) · 1.57 KB
/
Copy pathReviewLists.py
File metadata and controls
66 lines (40 loc) · 1.57 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# making a list into a dictionary
# list can be empty or full
listName = []
# listName.append(variable) adds something to the end of the list
# listName.insert(0, variable) inserts the variable to the location of the list
# del listName[0] removes the item in the location
# can get things out of the list by calling the item in the location
# -1 indicates the last item in the list, and - says count back from the end
# can also slice a list with [:1] and [1:]
# first indicates everything up to but not including the last number
# second indicates everything including the first number
listName.append("dog")
print (listName)
listName.append("cat")
print (listName)
del listName[0]
print (listName)
listName.insert(0, "horse")
print (listName)
listName.append("parrot")
print (listName)
listName.append("snake")
print (listName)
print (len(listName))
print (listName[-2])
print ("**********")
# dictionary is similar to a list that instead make pairs of items associated
# with each other
# one way of making a dictionary:
theDictionary = {"Key" : "Value", "Luna" : "Dog", "Chloe" : "Cat"}
# keys and values can be any noun (string, int, etc, can't be a list) in python
# keys cannot be the same but values can be
# use the keys to look up values like a human dictionary
# another way of making a dictionary:
theBlankDictionary = {}
theBlankDictionary["Goldie"] = "Goldfish"
# get things out of the dictionary by using keys, cannot use values
print(theDictionary ["Luna"])
print(theBlankDictionary["Goldie"])
# [] around key because it's basically indexing into a dictionary