---
author: izayak
title: "Ruotong's Chapter 7 Files Exercises"
layout: post
---

<iframe src="https://trinket.io/embed/python/053fad98d9" width="100%" height="600" frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>

  
**Reflection**  
At first I thought there was more than one floating number in each line of mbox-short.txt starting with 'X-DSPAM-Confidence:'. So I wrongly used the for loop and isintance() function. After I found the total variable would remain 0 and the line with isinstance() is correct, I printed items in the for loop and realized for loop should not be used there as it would give me individual characters and digits. Then I printed the line in the file and then converted it into a list with two components. The print is always helpful.  
Practice can help me find out that I am not really get some of the concepts. When I was working on the game app I realized that there were some unclear points in the previous chapters, I reread chapter 8 again and found the traversing part and converting between strings and lists very helpful.

---
author: izayak
title: "Ruotong's Chapter 7 Files Exercises"
layout: post
---

*Exercise 1-3*
<iframe src="https://trinket.io/embed/python/053fad98d9" width="100%" height="600" frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>


*Exercise 4* 
<iframe src="https://trinket.io/embed/python3/d0e622e00b" width="100%" height="356" frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>
  
  
**Reflection**  
At first I thought there was more than one floating number in each line of mbox-short.txt starting with 'X-DSPAM-Confidence:'. So I wrongly used the for loop and isintance() function. After I found the total variable would remain 0 and the line with isinstance() is correct, I printed items in the for loop and realized for loop should not be used there as it would give me individual characters and digits. Then I printed the line in the file and then converted it into a list with two components. The print is always helpful.  
Practice can help me find out that I am not really get some of the concepts. When I was working on the game app I realized that there were some unclear points in the previous chapters, I reread chapter 8 again and found the traversing part and converting between strings and lists very helpful.
The 4th exercise with introduction of list of lists can be very helpful when doing data analysis as it is a good way to form a table or a data structure. Although at first it is difficult to get what I want, it is a quite good exercise and I learned much from it.

Update Ruotong's Ch7 Files Exercises
Update Ruotong's Ch7 Files Exercises

add exercise 4