Week 6: Working with data
This week we were introduced to dictionaries.
The first task was to write a function whose input is string of text; and output a dictionary where the words from the stringare the keys, and the number of times they occur the values. I had to use a string method to split the string into a list of words; then iterate over the list, each time either adding a new dictionary or increasing a value
![](https://static.wixstatic.com/media/aa724d_8f831852921a4649acd9aa7c341e44bc.png/v1/fill/w_378,h_314,al_c,q_85,enc_auto/aa724d_8f831852921a4649acd9aa7c341e44bc.png)
The second task was to create a function codeOnly that removes all comments (everything that starts with #) from a script. It was tested on the script above.
![](https://static.wixstatic.com/media/aa724d_f7186d2b65ee426fb0a18ade8f6a5484.png/v1/fill/w_461,h_255,al_c,q_85,enc_auto/aa724d_f7186d2b65ee426fb0a18ade8f6a5484.png)
And the last task i did was to write a function to compare two text files. The function should print out the difference and in which line was the difference
![](https://static.wixstatic.com/media/aa724d_b0b75331b7f14e1b9c06e1bc130b24b0.png/v1/fill/w_547,h_404,al_c,q_85,enc_auto/aa724d_b0b75331b7f14e1b9c06e1bc130b24b0.png)