范围内的Python数不起作用 def range_测试(num): 如果1

范围内的Python数不起作用 def range_测试(num): 如果1,python,range,Python,Range,我的程序只是打印“输入一个数字:”作为输出? 你能找出原因吗? 谢谢 您尚未调用该函数。输入后,需要:range\u test(num)来调用函数。如果要打印输出,还需要打印返回值 完整计划应为: def def range_test(num): if 1 < num < 550 : return( "{:d} is in range.".format(num)) else: return("The number you entered is outside

我的程序只是打印“输入一个数字:”作为输出? 你能找出原因吗?
谢谢

您尚未调用该函数。输入后,需要:
range\u test(num)
来调用函数。如果要打印输出,还需要打印返回值

完整计划应为:

def def range_test(num):
  if 1 < num < 550  :
    return( "{:d} is in range.".format(num))
  else:
    return("The number you entered is outside the range!")
num = int(input("Enter a number: "))
def范围_测试(num):
如果1
#下面给出的操作代码。它工作得很好
def范围_测试(数值):
如果1
因为您的代码从未尝试打印任何其他内容?您可能需要调用range_test并打印结果
def range_test(num):
  if 1 < num < 550  :
    return( "{:d} is in range.".format(num))
  else:
    return("The number you entered is outside the range!")
num = int(input("Enter a number: "))
print(range_test(num))
# manipulated code given below. it is working perfectly
def range_test(num):
   if 1 < num < 550  :
       return( "{:d} is in range.".format(num))
   else:
       return("The number you entered is outside the range!")

num = int(input("Enter a number: "))
s1=range_test(num)
print"%s"%(s1)