exDotaPro

15_june_2019_6_favorite_movie

Jan 21st, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. command = input()
  2.  
  3. movies_checked = 0
  4. current_score = 0
  5. biggest_score = 0
  6. biggest_title = ''
  7.  
  8. while command != 'STOP':
  9.     movie_title = command
  10.     current_score = 0
  11.     movies_checked += 1
  12.  
  13.     if movies_checked == 7:
  14.         print('The limit is reached.')
  15.         print(f'The best movie for you is {biggest_title} with {biggest_score} ASCII sum.')
  16.         break
  17.  
  18.     for index in range(len(movie_title)):
  19.         value = (ord(movie_title[index]))
  20.  
  21.         if 65 <= value <= 90:
  22.             value -= len(movie_title)
  23.         elif 97 <= value <= 122:
  24.             value -= len(movie_title) * 2
  25.  
  26.         current_score += value
  27.  
  28.         if current_score > biggest_score:
  29.             biggest_score = current_score
  30.             biggest_title = movie_title
  31.  
  32.     command = input()
  33.  
  34.     if command == 'STOP':
  35.         print(f'The best movie for you is {biggest_title} with {biggest_score} ASCII sum.')
Add Comment
Please, Sign In to add comment