问题描述
问题-在列表中打印特定索引的正确方法是什么。 My attempt comes from the answer to a similar exercise outlined here。预先感谢。
这是我的代码
temp = range(0,101,10)
tbl = []
tbl2 = []
for i in temp:
cel = i
tbl.append(cel)
fah = (i * 9/5) + 32
tbl2.append(fah)
print(cel,fah)
print('Celsius\t\tFahrenheit')
print('-------------------')
print(tbl(0) + ':\t\t',tbl2(0))
print('-------------------')
这是我的输出
解决方法
通过括号()调用函数。用方括号[0]来访问索引:
print(tbl[0] + ':\t\t',tbl2[0])