Python 同时在范围内循环用户输入

Python 同时在范围内循环用户输入,python,loops,python-3.x,while-loop,Python,Loops,Python 3.x,While Loop,我有一些代码,我想让用户输入一个介于1-100之间的数字,如果他们在这两者之间输入一个数字,它将打印(大小:(输入))并打破循环,但是,如果他们输入一个在1-100之外的数字,它将打印(大小:(输入)),然后继续重新要求他们输入一个数字,尽管我遇到了一些问题 c=100 while c<100: c=input("Size: ") if c == 1 or 2 or 3: print ("Size: "+c) break else:

我有一些代码,我想让用户输入一个介于1-100之间的数字,如果他们在这两者之间输入一个数字,它将打印(大小:(输入))并打破循环,但是,如果他们输入一个在1-100之外的数字,它将打印(大小:(输入)),然后继续重新要求他们输入一个数字,尽管我遇到了一些问题

c=100
while c<100:
    c=input("Size: ")
    if c == 1 or 2 or 3:
        print ("Size: "+c)
        break
    else:
        print ("Size: "+c)
        print ("Invalid input. Try again.")
c=100
而c应该这样做

c=input("Size: ")
while int(c)>100 or int(c)<1: 
    #Will repeat until the number is between 1 and 100, inclusively.
    #It will skip the loop if the value is between 1 and 100.

    print ("Size: "+c)
    print ("Invalid input. Try again.")
    c=input("Size: ")

#once the loop is completed, the code following the loop will run
print ("Size: "+c)
c=输入(“大小:”)

当int(c)>100或int(c)时,您甚至从未进入循环

c=100
while c<100:
c=100

而c“我遇到了一些问题”-什么问题?当问问题时,代码不起作用。告诉我们它是如何起作用的。你有错误吗?它提供了你意想不到的输出?到底出了什么问题?可能重复的可能重复的非常感谢!完美地工作