var1,var2 = input("Enter two digits a and b (0-9):").split(' ')
while True:
if (0 <= var1 <= 9) and (0 <= var2 <= 9):
result = var1+var2
print("The result is: %r." %result)
我使用Spyder Python 3.5编写此代码并尝试运行它。但是,此代码不起作用。
它揭示了&#34; (1)var1,var2 =输入(&#34;输入两位数a和b(0-9):&#34;)。split(&#39;&#39;); (2)TypeError:&#39; str&#39;对象不可调用&#34;
答案 0 :(得分:0)
a,b = map(int, input().split())
while True:
if (0 <= a <= 9) and (0 <= b <= 9):
c = a + b
break
print('%r' %c)