Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.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 3.x while循环有2个条件_Python 3.x_While Loop - Fatal编程技术网

Python 3.x while循环有2个条件

Python 3.x while循环有2个条件,python-3.x,while-loop,Python 3.x,While Loop,我一直在为一个小循环而挣扎。我不知道为什么我的while循环不工作。如果我删除两个条件中的一个,它会工作,但当两者都在一起时,它不会 temp = input("Choose between Fahreneit degrees 'f'' key or Celsius degrees 'c' key ") while temp != "f" or temp != "c" : temp = input("you must choose f or c") if (temp == "f") :

我一直在为一个小循环而挣扎。我不知道为什么我的
while
循环不工作。如果我删除两个条件中的一个,它会工作,但当两者都在一起时,它不会

temp = input("Choose between Fahreneit degrees 'f'' key or Celsius degrees 'c' key ")

while temp != "f" or temp != "c" :
 temp = input("you must choose f or c")

if (temp == "f") :
 print("you choosed Fahreneit")
 degF = int(input("What is the temperature outside?"))
 print("It seems that the temperature is around" , (0.56 * (degF - 32)) ,"Celsius from your Fahreneit sample")

elif (temp == "c") :
 print("you choosed Celsius")
 degC = int(input("What is the temperature outside?"))
 while degC < -273 or degC > 5500 :
  degC = int(input("Please enter a correct value"))

print("it seems that the temperature is around" , (1.8 * (degC) + 32) , "Fahreneit from your Celsius sample")
temp=input(“在华氏度键或摄氏度键之间选择”)
当临时工!=“f”或温度!=“c”:
温度=输入(“您必须选择f或c”)
如果(温度=“f”):
打印(“您选择了Fahreneit”)
degF=int(输入(“室外温度是多少?”)
打印(“温度似乎在”、(0.56*(degF-32))、“华氏度样本的摄氏度左右”)
elif(温度=“c”):
打印(“您选择了摄氏度”)
degC=int(输入(“室外温度是多少?”)
当degC<-273或degC>5500时:
degC=int(输入(“请输入正确的值”))
打印(“温度似乎在”,(1.8*(degC)+32),“从您的摄氏样品中提取的华氏温度”)
temp!=“f”或温度!=“c”
不是与“f”或“c”相反。有关布尔表达式求反的指导,请参见

尝试:

或者只是:

while not (temp == "f" or temp == "c"):
或者完全跳过布尔头痛:

while temp not in ("f", "c"):
temp!=“f”或温度!=“c”
不是与“f”或“c”相反。有关布尔表达式求反的指导,请参见

尝试:

或者只是:

while not (temp == "f" or temp == "c"):
或者完全跳过布尔头痛:

while temp not in ("f", "c"):

“我一直在为一个小便便而奋斗。”-经典。一个空格是不够的-为了可读性遵循四个空格并缩进“我一直在为一个小便便而奋斗。”-经典。一个空格是不够的-为了可读性遵循四个空格并缩进很多凯文,我不得不说我不知道德摩根定律。答案是第一次尝试你的名单。非常感谢凯文,我不得不说我不知道德摩根定律。答案是第一次尝试你的名单。