Skip to content

Commit 2129673

Browse files
committed
thanks pb122-two
1 parent 4a98105 commit 2129673

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
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/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('Akuli')
328+
if 'Akuli' in namelist:
329+
print("Now I know Akuli!")
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)