@@ -110,25 +110,13 @@ Data types representing True bool:
110
110
111
111
` shopping_list[2] # cherries `
112
112
113
- - Elements in a list can be accessed in a range:
114
-
115
- ` shopping_list[0:2] # ['cereals', 'milk'] `
116
-
117
- - If the list is too big to count the elements, the last one can be accessed with a shortcut:
118
- ` shopping_list[-1] # cherries `
119
-
120
-
121
- - A list can be reversed:
122
-
123
- ` shopping_list[::-1] # ['cherries', 'milk', 'cereals'] `
124
-
125
113
126
114
127
115
### Tuples
128
116
- A tuple is very much like a list, however:
129
- - A tuple is an ordered sequential data type which is ** unchangeable **
117
+ - A tuple is an ordered sequential data type which is ** immutable **
130
118
- A tuple is created by a sequence of elements separated by a comma
131
- - For better readability, it is surrounded by parenthesis
119
+ - For better readability, it can be surrounded by parenthesis
132
120
133
121
Example:
134
122
@@ -141,9 +129,9 @@ Example:
141
129
` better_readability = ('with', 'parenthesis') `
142
130
143
131
### Sets
144
- - A set is an ** unordered** sequential data type
145
- - A set's element cannot be accessed by its index
146
- - A set is created by a pair of curly brackets:
132
+ - A set is an ** unordered** data type
133
+ - Elements of a set cannot be accessed by their indices
134
+ - A set is created by a single pair of curly brackets:
147
135
148
136
` shopping_list = {'apples', 'milk', 'cherries'} `
149
137
@@ -155,11 +143,7 @@ curly braces, keys and values
155
143
156
144
Example:
157
145
```
158
- employees = {
159
- 'ID': 16915,
160
- 'name': 'James',
161
- 'department': ['Sales', 'Accounting']
162
- }
146
+ employees = {'ID': 16915, 'name': 'James', 'department': ['Sales', 'Accounting']}
163
147
```
164
148
165
149
- A dictionary is accessed by keys as such:
0 commit comments