如何完成这while迴圈

我想要的是可以一直问问题,而且回答年龄小于1就会break,在年龄在6跟12之间再问有没有父母

在线等...

我目前写的如下:

age=int(input("请输人你的年纪:"))

while True:

    if age >=6 and age <=12:            with_parent = input("和父母一起来吗?(Y/N)")            if (age >= 6 and age <= 12) and (with_parent == 'Y' or with_parent == 'y'):                    print("可以看保护级电影")                    age = int(input("请输人你的年纪:"))    if age>=18:            print("可以看限制级电影")    elif age >12:            print("可以看辅导级电影")    else:            print("只能看普通级电影")

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章