代码运行但不能完全运行(python)

问题描述 投票:0回答:0
opt = input(
    "\n1. Enter 'a' to add a movie.\n2. Enter 'l' to see your movies.\n3. Enter 'f' to find a movie by title.\n4. Enter 'q' to quit: ")


def add(list):
    title = input("Enter the movie title: ")
    director = input("Enter the movie director: ")
    year = input("Enter the movie release year: ")
    list.append({
        'title': title,
        'director': director,
        'year': year
    })
    return list


def show(list):
    for movies in list:
        print(movies)


def detail(list):
    title = input("Enter the movie title: ")
    for movies in list:
        if title == movies['title']:
            print(list[0])
    else:
        print("Match not found")


movie = []

while opt != "q":
    if opt == "a":
        add()
    elif opt == "l":
        show(movie)
    elif opt == "f":
        detail(movie)
    opt = input(
        "\n1. Enter 'a' to add a movie.\n2. Enter 'l' to see your movies.\n3. Enter 'f' to find a movie by title.\n4. Enter 'q' to quit: ")


我是 python 的新手,所以我一定在不知不觉中犯了很多错误,请澄清。 (我想我在传递参数时犯了一些错误)

我做了 3 个功能 add 功能存储我使用的电影详细信息 show 功能显示所有显示的电影的详细信息 detail 功能在用户输入电影标题时提供特定电影的详细信息

python python-3.x performance pycharm
© www.soinside.com 2019 - 2024. All rights reserved.