Doubt movie data set

Please explain the for loop ,if,else for the freq_titles

Inside the for loop we are first calculating the length of a particular movie title by iterating in the titles list.Then as we have to plot a graph for movie length(in x ) and the frequency of movie names of lenght x, therefore each of the lenght of movie_title is being appended in a dictionary.The disctionary will have {“Unique_Lenght”: “Frequency of movies with that length”}

Therefore for each new movie_length we creating a new key value pair and storing its value as 1.But if we have encountered the same length again then it would mean that there already exists some movie with the same name. Therefore in that case we are just increasin the frequency or value of the that “length” key in our dictionary.

So for a movie say avatar the dictionary entry would by (6:1). As 6 is the length of movie_title as frequency is 1 as we have not encountered any previous movie_titles with title length 1. But if we encounter another movie while iterating say matrix. Then the dictionaly key value pair of (6:1) will get updated to (6:2). As now we have another movie named matrix of same length which already existed in the dictionary. So the frequency of movie_count will increase and be updated only.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.