我应该将此处作为输入的两个数字进行比较。我的问题是,无论输入多少,我只能得到一个输出。我想我在列表迭代的某个地方出错了。 还请告诉我,如果我在[A]和[B]中使用“ for i”而不是“在range(len(A))中的i”“为什么会出错?
import math
T = int(raw_input())
A = []
B = []
for i in range(0,T):
a,b = raw_input().split()
a = int(a)
b = int(b)
A.append(a)
B.append(b)
k = len(A)
for i in range(k):
if A[i] > B[i]:
print ">"
elif A[i] < B[i]:
print "<"
elif A[i] == B[i]:
print "="
答案 0 :(得分:1)
在我看来是一个意向性问题。
确保在for循环中有A.append(a)
import math
T = int(raw_input())
A = []
B = []
for i in range(0,T):
a,b = raw_input().split()
a = int(a)
b = int(b)
A.append(a)
B.append(b)
# k = len(A)
for i in range(len(A)):
if A[i] > B[i]:
print ">"
elif A[i] < B[i]:
print "<"
elif A[i] == B[i]:
print "="