在if后可以加几个判断条件?
def panduan(x,y):
if y in x:
print('yes!')
elif y.title() in x:
print('yes!')
elif y.lower() in x:
print('yes!')
elif y.upper() in x:
print('yes!')
else:
print('no!')
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena','Alice']
name_set=set(names)
name='bob'
panduan(name_set,name)为什么上面这段程序ok,但下面这种就判断不了呢?只返回yes!,无论name在不在name_set中。
if y or y.title() or y.lower() or y.upper() in x:
谢谢!