Skip to content

Commit 32a6259

Browse files
committed
2 parents 7f3972c + fdd3d7e commit 32a6259

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

basics/answers.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,12 @@ isn't exactly like mine but it works just fine it's ok, and you can
158158

159159
## Lists and tuples
160160

161-
1. When we run the program we get a weird error:
161+
1. Look carefully. The `namelist` is written in `()` instead of `[]`,
162+
so it's actually a tuple, not a list. Using confusing variable names
163+
is of course a bad idea, but you shouldn't be surprised if someone
164+
is doing that. Replace the `()` with `[]` and the code will work.
165+
166+
2. When we run the program we get a weird error:
162167

163168
Hello!
164169
Enter your name: my name
@@ -189,7 +194,7 @@ isn't exactly like mine but it works just fine it's ok, and you can
189194
Python created a tuple automatically, but that's not what we
190195
wanted. If we remove the comma, everything works just fine.
191196

192-
2. Again, the code gives us a weird error message.
197+
3. Again, the code gives us a weird error message.
193198

194199
Enter your name: my name
195200
Traceback (most recent call last):

basics/dicts.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ Dictionaries have some similarities with lists. For example, both
111111
lists and dictionaries have a length.
112112

113113
```python
114-
>>> len(names_and_pets) # contains two elements
115-
2
116-
>>> len(favorite_pets) # contains two key:value pairs
117-
2
114+
>>> len(names_and_pets) # contains three elements
115+
3
116+
>>> len(favorite_pets) # contains three key:value pairs
117+
3
118118
>>>
119119
```
120120

basics/lists-and-tuples.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,24 @@ else:
320320

321321
## Exercises
322322

323-
1. Fix this program.
323+
1. Fix this program:
324+
325+
```python
326+
namelist = ('wub_wub', 'RubyPinch', 'go|dfish', 'Nitori')
327+
namelist.append('pb122')
328+
if 'pb122' in namelist:
329+
print("Now I know pb122!")
330+
```
331+
332+
2. Fix this program.
324333

325334
```python
326335
print("Hello!")
327336
name = input("Enter your name: "),
328337
print("Your name is " + name + ".")
329338
```
330339

331-
2. Fix this program.
340+
3. Fix this program.
332341

333342
```python
334343
namelist = ['wub_wub', 'RubyPinch', 'go|dfish', 'Nitori']

0 commit comments

Comments
 (0)