@@ -14,19 +14,19 @@ for a reason. Let's look at this:
1414
1515``` python
1616>> > stuff = 1
17- >> > def set_stuff ():
17+ >> > def thingy ():
1818... stuff = 2
1919...
20- >> > set_stuff ()
20+ >> > thingy ()
2121>> > stuff # this did NOT change to 2
22221
2323>> >
2424```
2525
2626The problem is that ` stuff ` is a
2727[ local variable] ( defining-functions.md#locals-and-globals ) inside the
28- ` set_stuff ` function. There are actually two variables called ` stuff ` ; the
29- local ` stuff ` in ` set_stuff ` , and the global ` stuff ` :
28+ ` thingy ` function. There are actually two variables called ` stuff ` ; the
29+ local ` stuff ` in ` thingy ` , and the global ` stuff ` :
3030
3131![ Global scope: stuff = 1. Local scope inside global scope: stuff = 2.] ( ../images/stuff-global-and-local.png )
3232
@@ -35,7 +35,7 @@ Of course, this is bad style because it's very confusing. To fix this, you
3535see below):
3636
3737``` python
38- def set_stuff ():
38+ def thingy ():
3939 global stuff
4040 stuff = 2
4141```
@@ -233,9 +233,9 @@ def validate_user_info():
233233 try :
234234 if int (room_number) <= 0 :
235235 # room_number is '0', or negative (e.g. '-2')
236- return " room number is negative "
236+ return " room number must be positive "
237237 except ValueError :
238- # int() failed, room_number is e.g. 'lol'
238+ # int(room_number ) failed, room_number is e.g. 'lol'
239239 return " room number is not an integer"
240240
241241 if ' ' in user_name:
@@ -419,7 +419,7 @@ you can import it and try out all the things as usual, and figure out what's
419419wrong:
420420
421421```python
422- >> > import userinfo
422+ >> > import userinfo # save the program to userinfo.py
423423>> > info = userinfo.UserInfo(' a' , ' b' , ' lol' , ' 123-456-7890' , ' 123-456-7890' )
424424>> > info
425425< userinfo.UserInfo object at 0x 7fd110f8ac88>
0 commit comments