Advertisement
Dimitar23308

My course work

Jun 10th, 2024 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.72 KB | None | 0 0
  1. #Здравейте господине, това е проекта ми. Идеята на проекта ми е програма, която запаметява филм, който си изгледал. Надявам се да ви хареса!
  2.  
  3. # това е без файлове:
  4.  
  5.  
  6. film_collection = []
  7. while True:
  8.     izbor = input("Choose to: add, remove, show, exit. Enter your choice: ").lower()
  9.  
  10.     if izbor == "add":
  11.         title = input("Enter the title of the film: ")
  12.         genre = input("Enter the genre of the film: ")
  13.         year =  input("Enter the release year of the film: ")
  14.         rating = input("Enter the rating of the film: ")
  15.  
  16.         film = {
  17.             'title': title,
  18.             'genre': genre,
  19.             'year': year,
  20.             'rating': rating
  21.         }
  22.         film_collection.append(film)
  23.         print("Film is added!")
  24.  
  25.     elif izbor == "remove":
  26.         title_to_remove = input("Enter the title of the film to remove: ")
  27.         for film in film_collection:
  28.             if film['title'] == title_to_remove:
  29.                 film_collection.remove(film)
  30.                 print(f"Film '{title_to_remove}' is removed !")
  31.                 break
  32.         else:
  33.             print(f"Film '{title_to_remove}' not found.")
  34.  
  35.     elif izbor == "show":
  36.         if film_collection:
  37.             print("Films in the collection:")
  38.             for film in film_collection:
  39.                 print(f"Title: {film['title']}, Genre: {film['genre']}, Year: {film['year']}, Rating: {film['rating']}")
  40.         else:
  41.             print("No films in the collection.")
  42.  
  43.     elif izbor == "exit":
  44.         print("Exiting the program.")
  45.         break
  46.  
  47.     else:
  48.         print("Invalid choice.")
  49.  
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement