【发布时间】:2015-09-17 02:03:34
【问题描述】:
def Tempurature(Lowest, Highest):
ok = False
while not ok:
try:
Input = int(input(print("\nEnter the Mid-Day tempurature for Day {}:".format(Counter))))
if Input >= Lowest and Input <= Highest:
ok = True
return Input
else:
print ("Please enter a valid number between {} and {}".format(Lowest, Highest))
except:
print ("Please enter a number")
这是我的函数,我用它来将数字输入到这样的数组中
Counter = int(1)
TempDay = array.array ("i", range(31))
TempDay[Counter] = (Tempurature(-90, 60))
但是,当我调用该函数时,会打印以下内容
Enter the Mid-Day tempurature for Day 1:
None
关于如何摆脱“无”打印以使输入行位于“:”而不是“无”末尾的任何解决方案?
【问题讨论】:
-
尝试在输入功能中删除打印
-
另外,只是为了编程约定:变量、参数和函数(或方法,如果你称之为)应该以小写字母开头。类应以大写字母开头。如果其他人要阅读您的代码(如果它是一个复杂的程序),如果他们快速阅读它,他们可能会感到困惑。不过也没什么大不了的。