#!/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)!