result = [{'line': 'johannsasuke@gmail.com:42ab89', 'sources': ['Taringa.net'], 'last_breach': '2017-08'}, {'line': 'johannsasuke@gmail.com:PEIN12345', 'sources': ['Evony.com'], 'last_breach': '2016-07'}, {'line': 'johannsasuke@gmail.com:sasuke12345', 'sources': ['Animoto.com', 'Collection 1', 'xSplit'], 'last_breach': '2019-01'}, {'line': 'johannsasuke@gmail.com', 'sources': ['xSplit'], 'last_breach': '2013-11', 'email_only': 1}]
for x in result:
if result['email_only']==1:
pass
else:
print(result['line'])
I'm trying to print the combos that are released with this api but am getting TypeError: list indices must be integers or slices, not str. Please help!
result
is a list, so you probably meant x
, as this is your item:
for x in result:
if x.get("email_only") == 1:
continue
print(x["line"])
Prints:
johannsasuke@gmail.com:42ab89
johannsasuke@gmail.com:PEIN12345
johannsasuke@gmail.com:sasuke12345
NOTE: I used x.get()
, because it returns None
if key email_only
doesn't exist in the dictionary (not throwing exception).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.