语法:IF
#!/usr/bin/env python
# -*- coding: utf-8 -*-
l = [2,3,4,9]
if 1 in l:
print 1, "in the list"
elif 2 in l:
print 1,"NOT in the list"
print 2, "in the list"
else:
print 1,2,"NOT in the list"
运行结果:
% python gramma/if.py ✭
1 NOT in the list
2 in the list