我的代码几乎是这样的:
Rate = input ("Enter Desired Rate of Charge: ") #User will be prompted to enter the charge rate of the system
if Rate < 0.5:
#If the charge rate entered is less than 0.5 kWhs
print "Charge Rate Too Low: Please consider revision" #Tells the user the rate is too low
elif Rate > 2.0:
#Also, if the charge rate entered is greater than 2.0 kWhs...
print "Charge Rate Too High: Please consider revision" #Tells the user the rate is too high
else:
#Otherwise, for any number entered between the bounds of 0.5 and 2.0 kWhs...
print '\n' #Page break for new conditions.
如果输入的整数小于 0.5 或大于 2,我需要它重新提示用户,当用户这样做时,将该整数保存为 Rate 并继续。谢谢你。