Web Addresses List¶

Objects are nice, but they’re even better when used with a list.

The code provided does the same as the previous assignment, but uses an array of objects, instead of one variable for each record.

What You Should See¶

1. 191 Marigold Lane, Miami, FL  33179
2. 3029 Losh Lane, Crafton, PA  15205
3. 4939 Holt Street, Lake Worth, FL  33463
4. 2693 Hannah Street, Hickory, NC  28601
5. 4880 Carter Street, Fairview Heights, IL  62208

What You Should Do on Your Own¶

Assignments turned in without these things will receive half credit or less.

  1. The code provided counts up to 18 in the first loop instead of using the len() function on the list file_lines. Fix this.

  2. The code is also using the value 5 to print out the addresses list. Use the len() function on that list too for that loop. Ensure that all six addresses are read in.

  3. What happens if you simply print the address variable? In your loop, print out print(address) and observe. What do you suppose it might mean? Wouldn’t it be nice if, when you print the variable directly, it would display something more intelligible? We will take care of that in the next exercise.


©2021 Daniel Gallo

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.

Creative Commons License

Adapted for Python from Graham Mitchell’s Programming By Doing