Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.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 - Fatal编程技术网

Python 第二次输入不起作用

Python 第二次输入不起作用,python,Python,当给出大于2的无效答案并将其发送回introname时,请参见底部的else语句,该语句为简介,选项1将自动完成并重定向到crowbar 在本例中,您可以使用带有参数的函数x def car(x): if x == 1: print("crowbar()") elif x == 2: print("door()") else: print("that's not a valid answer") p

当给出大于2的无效答案并将其发送回introname时,请参见底部的else语句,该语句为简介,选项1将自动完成并重定向到crowbar


在本例中,您可以使用带有参数的函数x

def car(x):
   if x == 1:
          print("crowbar()")
   elif x == 2:
          print("door()")
   else:
          print("that's not a valid answer")
          print("intro(name)")

choise1 = int(input("enter 1 or 2"))
car(choise1)

这是相当不清楚的。具体发生了什么,您希望发生什么?很模糊,您想说什么?我认为您需要在函数内部传递参数。carchoise1还通过def carchoise1定义您的功能:欢迎访问该站点。请在car函数中添加函数调用的完整代码。@Carcigenicate我希望这个程序让我在给出错误答案并完成介绍后选择1或2。我认为这不是问题的答案。虽然不推荐使用,但函数始终可以引用全局参数。@khaldi yazid只是重复代码,但不允许我选择1或2
def car(x):
   if x == 1:
          print("crowbar()")
   elif x == 2:
          print("door()")
   else:
          print("that's not a valid answer")
          print("intro(name)")

choise1 = int(input("enter 1 or 2"))
car(choise1)