Skip to content

Commit 60c2d78

Browse files
committed
fixes
1 parent bcec00e commit 60c2d78

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

basics/answers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ isn't exactly like mine but it works just fine it's ok, and you can
6666
```python
6767
no_space = input("Enter a word: ")
6868
yes_space = no_space + " "
69-
print(yes_space * 999 + no_space)
69+
print(yes_space*999 + no_space)
7070
```
7171

7272
5. Like this:
@@ -79,21 +79,20 @@ isn't exactly like mine but it works just fine it's ok, and you can
7979
```
8080

8181
6. We can compare the word against an empty string (`""` or `''`) to
82-
check if it's empty. In this example, the password is "s3cr3t".
82+
check if it's empty. In this example, the password is "seKr3t".
8383

8484
```python
8585
word = input("Enter your password: ")
8686

87-
if word == "s3cr3t":
87+
if word == "seKr3t":
8888
print("Welcome!")
8989
elif word == "":
9090
print("You didn't enter anything.")
9191
else:
9292
print("Access denied.")
9393
```
9494

95-
This is not a good way to ask a password from the user because the
96-
password isn't hidden in any way, but this is just an example.
95+
Again, this is not a good way to ask a real password from the user.
9796

9897
## Handy stuff: Strings
9998

@@ -219,7 +218,8 @@ isn't exactly like mine but it works just fine it's ok, and you can
219218
problems and solutions:
220219

221220
- `namelist` is None. It should be `namelist.extend('theelous3')`,
222-
not `namelist = namelist.extend('theelous3')`.
221+
not `namelist = namelist.extend('theelous3')`. See [this
222+
thing](using-functions.md#return-values).
223223
- Now the namelist is like `['wub_wub', ..., 't', 'h', 'e', 'e', ...]`.
224224
Python treated `'theelous3'` like a list so it added each of its
225225
characters to `namelist`. We can use `namelist.append('theelous3')`

basics/defining-functions.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,20 +177,16 @@ However, modifying a global variable in-place from a function is easy.
177177
>>>
178178
```
179179

180-
This doesn't work if the value is of an immutable type, like string or
181-
integer because immutable values cannot be modified in-place.
182-
Fortunately, Python will tell us if something's wrong.
180+
This only works for changing in-place, we cannot assign a new value to
181+
the variable.
183182

184183
```python
185-
>>> thing = 1
186-
>>> def stuff():
187-
... thing += 1
184+
>>> def set_stuff_to_something_new():
185+
... stuff = ['more local stuff']
188186
...
189-
>>> stuff()
190-
Traceback (most recent call last):
191-
File "<stdin>", line 1, in <module>
192-
File "<stdin>", line 2, in stuff
193-
UnboundLocalError: local variable 'thing' referenced before assignment
187+
>>> set_stuff_to_something_new()
188+
>>> stuff
189+
['global stuff', 'local stuff']
194190
>>>
195191
```
196192

@@ -262,10 +258,6 @@ This function can be called in two ways:
262258
because `message = "hi"` and `some_function(message="hi")` do two
263259
completely different things.
264260

265-
Personally, I would use this function with a positional argument. It
266-
only takes one argument, so I don't need to worry about which argument
267-
is which.
268-
269261
Now it's time to solve our box printing problem:
270262

271263
```python

getting-help.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ places to ask for help in.
55

66
## IRC
77

8-
IRC is the oldest chatting service I know, but as of 2017, it's still
8+
IRC is the oldest chatting service I know, but as of 2018, it's still
99
in use, and a great way to get help in Python. You don't need to
1010
register anywhere, just click one of the links below and you're good to
1111
go.

0 commit comments

Comments
 (0)