我正在尝试做一个可以做到这一点的程序
如果数字<1000多等于2,直到大于1000的数字
如果数字> 1000乘以3,则无穷大
x = input("the number")
while True:
if int(x) <1000:
x *= 2
print(int(x))
if int(x) >1000:
x *= 3
print(int(x))
,但它只会无限次数地写入数字。不相乘
我希望你理解我的问题
答案 0 :(得分:0)
x
不是整数,但是可以用鸭子的形式输入一个!检查一下:
x = int(input("the number\n"))
print(str(x) + '\n')
while True:
if x < 1000:
x *= 2
print(str(x) + '\n')
if int(x) > 1000:
break # my console prints too fast and starts deleting the first rows before I can stop the program