Rumah >pembangunan bahagian belakang >Tutorial Python >Python语法练习--if判断
#!/usr/bin/env python # -*- coding:utf8 -*- age = int(input("输入您的年龄")) if age < 18: print ("您是一名未成年") elif age > 18: print ("您是一名成年人") else: print ("输入错误,请重新输入") ----------------------------------------------- name_list = ["Jin","Tom","Cat","Jak","Sum"] if "Jin" in name_list: print ("Jin") else: print ("error")
以上就是Python语法练习--if判断的内容,更多相关内容请关注PHP中文网(www.php.cn)!