This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def manhattan(rating1, rating2): | |
| """Computes the Manhattan distance. Both rating1 and rating2 are | |
| dictionaries of the form | |
| {'The Strokes': 3.0, 'Slightly Stoopid': 2.5 ...""" | |
| distance = 0 | |
| for key in rating1: | |
| if key in rating2: | |
| distance += abs(rating1[key] - rating2[key]) | |
| return distance |