Home >Backend Development >Python Tutorial >Python syntax exercise--if judgment
#!/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")
The above is the content of Python grammar exercise-if judgment. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!