Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用时出现问题";否则";_Python_Python 3.x - Fatal编程技术网

Python 使用时出现问题";否则";

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

不知道我做错了什么。如果有人使用维基百科列表,维基百科的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):
  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中搜索给定值的任务(
列表在本例中为