Python 只要输入大于上一个输入,则循环

Python 只要输入大于上一个输入,则循环,python,Python,抱歉-只是一个简单的任务,要求更高的输入,除非它等于或小于以前的输入。 输入值是否需要一个占位符,或者我是否缺少一个中断 num=input(“输入一个数字:”) 尽管如此: num=num: 打印(“继续走高!”) 代码输出 有点不对劲 再试一次 导入系统 num_tmp=-sys.maxsize-1#此表达式返回尽可能低的数字 尽管如此: num=input(“输入一个数字”)#input返回字符串值 如果不是num.isdecimal():#检查输入是否只包含数字 打印(“不是数字,请重

抱歉-只是一个简单的任务,要求更高的输入,除非它等于或小于以前的输入。 输入值是否需要一个占位符,或者我是否缺少一个中断

num=input(“输入一个数字:”)
尽管如此:
num=num:
打印(“继续走高!”)
代码输出

有点不对劲 再试一次
导入系统
num_tmp=-sys.maxsize-1#此表达式返回尽可能低的数字
尽管如此:
num=input(“输入一个数字”)#input返回字符串值
如果不是num.isdecimal():#检查输入是否只包含数字
打印(“不是数字,请重试。”)
继续#跳过进一步的说明并转到下一个迭代
elif int(num)
导入系统
num_tmp=-sys.maxsize-1#此表达式返回尽可能低的数字
尽管如此:
num=input(“输入一个数字”)#input返回字符串值
如果不是num.isdecimal():#检查输入是否只包含数字
打印(“不是数字,请重试。”)
继续#跳过进一步的说明并转到下一个迭代
elif int(num)
num
num
import sys

num_tmp = -sys.maxsize - 1 # this expression returns lowest possible number
while True:
    num = input("Enter a number: ") # input returns string value

    if not num.isdecimal(): # checking if input contains only digits
        print("Not a number, try again.")
        continue # skips futher instructions and go to next iteration
    elif int(num) < num_tmp: # int(num) converts string to integer
        print("Entered number is lower that previous. That's all. Bye.")
        break # breaks loop execution ignoring condition

    num_tmp = int(num) # updating num_tmp for comparsion in next iteration
    print("Keep going higher!")