user_list = [["Account number","Currency","Balance"],
["001-987654-003","USD",1300.72],
["001-919202-100","EUR",105.01],
["001-905700-100","EUR",305.00],
["001-908415-307","CHF",20804.98],
["011-974777-200","PLN",208.15],
["001-931654-001","USD",450.7]]
def vlookup(lookupvalue,lookuplist,col_index):
try:
lookuplist = user_list
except Exception as e:
print(str(e))
else:
length1 = len(lookuplist[0])
length2 = len(lookuplist)
for j in range(length2):
if lookupvalue == lookuplist[j][0]:
if col_index - 1 in range(length1):
return print(lookuplist[j][col_index - 1])
else:
return print('Out of scope')
else:
continue
return print('Not found')
vlookup("001-919202-100",otheruserlist, 2)
Traceback (most recent call last):
File "C:\Users\Kevin Sun\untitled0.py", line 59, in <module>
vlookup("001-919202-100",otheruserlist, 2)
NameError: name 'otheruserlist' is not defined
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/226076.html
上一篇:請教一個Fortran語言問題
