Advertisement
pacho_the_python

Untitled

Oct 20th, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. import sys
  2. command = input()
  3.  
  4. max_points = -sys.maxsize
  5. movie_points = 0
  6. movie_counter = 0
  7. best_movie = ""
  8. best_points = 0
  9. while command != "STOP":
  10.  
  11.     movie_len = len(command)
  12.     movie_counter += 1
  13.     if movie_counter == 7:
  14.         print("The limit is reached.")
  15.         break
  16.  
  17.     for i in command:
  18.         if i.islower():
  19.             points = ord(i) - movie_len * 2
  20.             movie_points += points
  21.         if i.isupper():
  22.             points = ord(i) - movie_len
  23.             movie_points += points
  24.         if i == " ":
  25.             points = ord(i)
  26.             movie_points += points
  27.         if i in "1234567890":
  28.             points = ord(i)
  29.             movie_points += points
  30.     if movie_points > max_points:
  31.         max_points = movie_points
  32.         best_movie = command
  33.         best_points = max_points
  34.  
  35.     command = input()
  36.     movie_points = 0
  37.  
  38. print(f"The best movie for you is {best_movie} with {best_points} ASCII sum.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement