Advertisement
Spocoman

Favorite Movie

Feb 22nd, 2022 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. best_movie = ""
  2. best_ascii = 0
  3. counter = 0
  4. movie = input()
  5.  
  6. while movie != "STOP":
  7.     ascii_sum = 0
  8.     for j in range(len(movie)):
  9.         ascii_sum += ord(movie[j])
  10.         if 96 < ord(movie[j]) < 123:
  11.             ascii_sum -= len(movie) * 2
  12.         elif 64 < ord(movie[j]) < 91:
  13.             ascii_sum -= len(movie)
  14.  
  15.         if ascii_sum > best_ascii:
  16.             best_movie = movie
  17.             best_ascii = ascii_sum
  18.  
  19.     counter += 1
  20.     if counter == 7:
  21.         break
  22.     movie = input()
  23.  
  24. if counter == 7:
  25.     print("The limit is reached.")
  26.  
  27. print(f"The best movie for you is {best_movie} with {best_ascii} ASCII sum.")
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement