Learn Python 010: Dictionary - Cinema Simulator

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Learn Python 010: Dictionary - Cinema Simulator相关的知识,希望对你有一定的参考价值。

films = {
    ‘Finding Dory‘: [3, 5],
    ‘Bourne‘: [18, 7],
    ‘Tarzen‘: [15, 9],
    ‘Ghost Busters‘: [12, 5]
}

while True:
    choice = input(‘Please enter the selected film: ‘).title().strip()
    if choice in films:
        age = int(input(‘Please enter your age: ‘).strip())
        if age >= films[choice][0]:
            if films[choice][1] > 0:
                print(‘Enjoy.‘)
                films[choice][1] = films[choice][1] - 1
            else:
                print(‘Sorry, we are sold out.‘)
        else:
            print("Sorry, you are too young to watch the film.")

    else:
        print(‘Sorry, we do not have this film.‘)

 

以上是关于Learn Python 010: Dictionary - Cinema Simulator的主要内容,如果未能解决你的问题,请参考以下文章

标准库:collections之orderedDict

Linux作业 使用make命令和分析makefile文件

在python中,如何使用unicode内容订购dict?

[Python]?????????Python?????????010???(????????????????????????????????????)????????????????????????

python010-数组

python-010-字典