检查特定值是否包含在列表中
# if - 检查特定值是否包含在列表中num1 = ['aa', 'bb', 'ccc']print('aa' in num1)print('cc' in num1)
检查特定值是否不包含在列表中
num1 = ['aa', 'bb', 'ccc']num_find = 'd'if num_find not in num1: print(f'{num_find.title()}, not find!')

if-elif-else
#if-elif-elseage = 12if age < 4 : print("FREE!")elif age < 18 : print("50%!")else: print('FULL!')

确定列表不是空的
orders = ['apple', 'cola', 'hamberger']if orders: for order in orders: print(f'You ordered {order}.')else: print("What you want?")orders = []if orders: for order in orders: print(f'You ordered {order}.')else: print("What you want?")
使用多个列表
orders = ['apple','cola']requests = ['hamberger','apple']for request in requests: if request in orders: print(f"OK,{request} right now!") else: print(f"Sorry,we don't have {request}")
