numtodouble=int
result=int
print("")
print("Enter a number you would like to double and press Enter.")
input (numtodouble)
<class 'int'>2
'2'
while numtodouble>0:
result=numtodouble*2
print("2 X", numtodouble, "=", result)
print("")
print("Enter a number you would like to double and press Enter.")
input(numtodouble)
break
print("OK, you entered a value <=0, ending execution.")
有人知道我的代码哪里出错了吗?我已经挣扎了好几个小时了。在
这段代码要简单得多,可以完成您要做的事情。我假设您正在学习python,因此其中有些东西并不是最简单的方法,比如format函数,但是它们非常有用。在
^{pr2}$如果我能做的是最接近伪代码的。在这里使用变量之前声明变量是不必要的,而且很麻烦。就像伪代码不是要变成python一样。与打印空白行相同,这些空白行应包装到上一个或下一个打印行。在
相关问题 更多 >
编程相关推荐