Python 使用时出现问题";否则";
不知道我做错了什么。如果有人使用维基百科列表,维基百科的If将与其他人一起被删除Python 使用时出现问题";否则";,python,python-3.x,Python,Python 3.x,不知道我做错了什么。如果有人使用维基百科列表,维基百科的If将与其他人一起被删除 wikipedia=["search","infromation"] weatherfor=["show weather","weather today","weather forecast","weather"] action=(input("What would you want me to do : ")) if any(word in action for word in wikipedia): pri
wikipedia=["search","infromation"]
weatherfor=["show weather","weather today","weather forecast","weather"]
action=(input("What would you want me to do : "))
if any(word in action for word in wikipedia):
print("Here Is What I Found On Wikipedia.")
if any(word in action for word in weatherfor):
print("The Weather For Today Is")
else:
print ("Sorry I Haven't learnt this yet")
如果您过度使用了
if
else
,请尝试以下简单结构:
wikipedia=["search", "infromation"]
weatherfor=["show weather", "weather today", "weather forecast", "weather"]
action=(input("What would you want me to do : "))
if action in wikipedia:
print("Here Is What I Found On Wikipedia.")
elif aaction in weatherfor:
print("The Weather For Today Is")
else:
print ("Sorry I Haven't learnt this yet")
中的
可以在任何iterable(列表,在本例中为)中搜索给定的值如果
,请尝试以下简单结构:
wikipedia=["search", "infromation"]
weatherfor=["show weather", "weather today", "weather forecast", "weather"]
action=(input("What would you want me to do : "))
if action in wikipedia:
print("Here Is What I Found On Wikipedia.")
elif aaction in weatherfor:
print("The Weather For Today Is")
else:
print ("Sorry I Haven't learnt this yet")
中的将执行在任何iterable中搜索给定值的任务(列表在本例中为)