Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.16 KB | None | 0 0
  1. import random
  2. import sys
  3. loaded = False
  4. last_choice = []
  5. keep = []
  6.  
  7.  
  8. def random_movie():
  9.     lists = random.choice(movies_list)
  10.     print(lists)
  11.     last_choice.append(lists)
  12.     movie_title_explorer()
  13.  
  14.  
  15. def load():
  16.     global movies_list
  17.     file_to_open = input("Enter the file to open ")
  18.     file = open(file_to_open, "r")
  19.     movies_list = file.readlines()
  20.     movies_list = [movie.strip() for movie in movies_list]
  21.     file.close()
  22.     print(movies_list)
  23.     movie_title_explorer()
  24.  
  25.  
  26. def search():
  27.     user_input = input("Enter a movie title ")
  28.     for x in range(0, len(movies_list)):
  29.         if movies_list[x].__contains__(user_input):
  30.             print(movies_list[x])
  31.     movie_title_explorer()
  32.  
  33.  
  34. def starts_with():
  35.     user_input = input("Enter a letter to search for ")
  36.     for x in range(0, len(movies_list)):
  37.         if movies_list[x].startswith(user_input):
  38.             last_choice.append(movies_list[x])
  39.             print(movies_list[x])
  40.     movie_title_explorer()
  41.  
  42.  
  43. def movie_title_explorer():
  44.     print("""*** Movie Title Explorer ***
  45. l – load file of movie titles
  46. r – random movie
  47. s – search
  48. sw – starts with
  49. k – keep - save the last displayed movie title to your favourites
  50. f – favourites display
  51. c – clear favourites
  52. q – quit """)
  53.     user_input = input("Choose an item ")
  54.     user_input = user_input.lower()
  55.     while user_input not in["l", "r", "s", "sw", "k", "f", "c", "q"]:
  56.         try:
  57.             user_input = input("Choose a valid item ")
  58.         except ValueError:
  59.             print("Please enter l r s sw k f c q")
  60.     if user_input == "l":
  61.         load()
  62.     if user_input == "r":
  63.         random_movie()
  64.     if user_input == "s":
  65.         search()
  66.     if user_input == "sw":
  67.         starts_with()
  68.     if user_input == "k":
  69.         keep.append(last_choice)
  70.         movie_title_explorer()
  71.     if user_input == "f":
  72.         print(keep)
  73.         movie_title_explorer()
  74.     if user_input == "c":
  75.         for y in range(len(keep)):
  76.             del keep[y]
  77.         movie_title_explorer()
  78.     if user_input == "q":
  79.         print("Have a good day")
  80.         sys.exit()
  81. movie_title_explorer()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement