码迷,mamicode.com
首页 > 编程语言 > 详细

Learn Python 010: Dictionary - Cinema Simulator

时间:2017-07-15 17:50:11      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:rip   out   ict   cin   python   dict   str   put   logs   

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

标签:rip   out   ict   cin   python   dict   str   put   logs   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!