首页 > 编程语言 > 详细

Learn Python 010: Dictionary - Cinema Simulator

时间:2017-07-15 17:30:56      阅读:312      评论:0      收藏:0      [点我收藏+]
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

原文:http://www.cnblogs.com/mxyzptlk/p/7183388.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!