我在Python代码中没有发现的错误在哪里?

2024-09-28 22:28:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我找不到错误。我将非常感谢您的帮助!先谢谢你

“”“ 该程序要求用户提供三种成分, 三份数量和若干份服务,以及 确定每种成分需要多少 提供指定数量的食物。 “”“

ingredient_one = input("What is the first ingredient?: ")
ing_one_oz = int(input("How many ounces of this ingredient?: ")

ingredient_two = input("What is the second ingredient?: ")
ing_two_oz = int(input("How many ounces of this ingredient?: ")

ingredient_three = input("What is the third ingredient?: ")
ing_three_oz = int(input("How many ounces of this ingredient?: ")



servings_amt = int(input("How many servings would you like?: ")

ing_one_oz = ing_one_oz * servings_amt
ing_two_oz = ing_two_oz * servings_amt
ing_three_oz = ing_three_oz * servings_amt

print("In order to make " + str(servings_amt) + " servings of your recipe, you will need " + str(ing_one_oz) + " ounces of " /
+ str(ingredient_one) + ", " + str(ing_two_oz) + " ounces of " + str(ingredient_two) + ", and " + str(ing_three_oz) /
+ " ounces of " + str(ingredient_three) + ".")

输出在第3行显示一个语法错误,该行以变量concentrator_two开头。 第1行已作为“正确”通过,但第3行没有,即使它们实际上是相同的


Tags: ofinputonemanyhowintthreetwo
3条回答

错误在第2行、第4行、第6行和第7行,即ing#U一盎司、ing#U二盎司、ing#U三盎司、服务金额。在将输入键入“int”时,请关闭括号

你的错误在第2行。你需要在一盎司的末尾加一个括号

ing_one_oz = int(input("How many ounces of this ingredient?: ")

Python很有趣,它能发现前面几行中出现的错误

我不是python专家,但是

int(input("How many ounces of this ingredient?: ")

不需要第二个“)”

相关问题 更多 >