Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Jun 24, 2017
2 parents 7f3972c + fdd3d7e commit 11a03c6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
9 changes: 7 additions & 2 deletions basics/answers.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ isn't exactly like mine but it works just fine it's ok, and you can

## Lists and tuples

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

2. When we run the program we get a weird error:

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

2. Again, the code gives us a weird error message.
3. Again, the code gives us a weird error message.

Enter your name: my name
Traceback (most recent call last):
Expand Down
8 changes: 4 additions & 4 deletions basics/dicts.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ Dictionaries have some similarities with lists. For example, both
lists and dictionaries have a length.

```python
>>> len(names_and_pets) # contains two elements
2
>>> len(favorite_pets) # contains two key:value pairs
2
>>> len(names_and_pets) # contains three elements
3
>>> len(favorite_pets) # contains three key:value pairs
3
>>>
```

Expand Down
4 changes: 3 additions & 1 deletion basics/docstrings.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ def do_hello():

Then we can import it and call help on it:

```python
[comment]: # (github screws up syntax highlighting here)

```
>>> import test
>>> help(test)
Help on module testie:
Expand Down
13 changes: 11 additions & 2 deletions basics/lists-and-tuples.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,24 @@ else:

## Exercises

1. Fix this program.
1. Fix this program:

```python
namelist = ('wub_wub', 'RubyPinch', 'go|dfish', 'Nitori')
namelist.append('pb122')
if 'pb122' in namelist:
print("Now I know pb122!")
```

2. Fix this program.

```python
print("Hello!")
name = input("Enter your name: "),
print("Your name is " + name + ".")
```

2. Fix this program.
3. Fix this program.

```python
namelist = ['wub_wub', 'RubyPinch', 'go|dfish', 'Nitori']
Expand Down

0 comments on commit 11a03c6

Please sign in to comment.