Learning to think in code is not easy if you've never programmed before. If you need a nudge along the way while solving the IMDb problems presented in class, here follows some pseudocode/advice for each task. There will be no answers in here, just tips and advice in how to solve the problems.
if/else
statement to check if the genre is present as a key in the dictionary. If it is not, add it as a key with the value 1 (as this is the first occurrence of the genre). Remember to think about the upper/lower case problem, and make everything lowercase before comparing or adding to the dictionary.integer
to get the number of whole hours.runtime-(hours*3600)/60
. As we don't care about the seconds, you can just round the minutes.This is a tricky one!
sys.argv
and use for defining input- and output files on the command line.{'drama': [[8.5, 'Movie1', 1987, '1h42min'], [7.3, 'Movie2', 1999, '2h12min']].....}
write
mode.for genre in dictionary
, where you write the genre to file. Then for movie in genre
to write the information for each movie under the correct genre.