cars = ['bmw','audi','byd','jeep']
for car in cars:
if car == 'audi': #Python中检查是否相等时区分大小写
print(car.upper())
else:
print(car.title())
# !=判断两个值是否不等
# and or in not in
age = 12
if age < 4:
print('you are too young')
elif age < 18:
print('you are young')
else: # else代码块可省略
print('you are old')
print('\n')
available_toppings = ['mushrooms','olivers','green peppers','pineapple']
requested_toppings = ['mushrooms','french fries','green peppers']
for requested_topping in requested_toppings:
if requested_topping in available_toppings:
print('Adding '+requested_topping+'.')
else:
print("Sorry,we don't have "+requested_topping+'.')
print('\nFinished making your pizza!')