Exercise 3

螢幕快照 2016-07-08 下午11.25.38.png

Due to the string type in the text, when conducting the input function I have to set the type to string in advance, or ‘TypeError’ would show up; Also, the start number of my search has to be updated or the loop would never end.


Exercise 4

未命名.png

螢幕快照 2016-07-09 上午12.07.35

Because it’s a nested dictionary, the first thing is to extract zip info from each city, and then retrieve the zip code values from the sub-dictionary.

螢幕快照 2016-07-09 上午12.17.20

螢幕快照 2016-07-09 上午12.09.05

螢幕快照 2016-07-09 上午12.19.23

The default type of input is set to be string, so I have to add an integer function outside, and set a foolproof mechanism to avoiding breaking the loop without getting an appropriate value.

 

發表留言