从键盘读入若干个实数,以-1结束,保存于列表L1中。输出列表中每一元素的下标及元素本身。
L1=[];num=0;
while True:
num=int(input("Num "))
if num == -1: break
L1.append(num)
for e in L1:
print(e,L1[e])
L1=[];num=0;
while True:
num=int(input("Num "))
if num == -1: break
L1.append(num)
for e in L1:
print(e,L1[e])
for i in range(len(L1)):
print(i, L1[i])
for ind, val in enumerate(L1):
print(ind, val)