我已经从数据库中检索到总统并创建了一个列表。现在,我需要根据用户提供的PNAME检索4位PIN。下面是生成的列表。
['George Bush 6182', 'John Kennedy 5860', 'Barrack Obama 6394', 'Harry Truman 6478', 'Richard Nixon 7155']
我试过循环浏览列表,但没有成功。
full_list = []
pName = message[cmd_index + 2]
p_map_snapshot = db_root.child('pMap').get()
p_id = p_map_snapshot[message[cmd_index + 1].lower()]
roster_snapshot = db_root.child('rosters').child(p_id).get()
print (pName)
for prez in roster_snapshot:
full_list.append((prez['firstName'] + " " + prez['lastName'] + " " + str(prez['pinId'])))
#LOOP HERE?
#if pName == ?
#print(full_list)