07-30-2019 03:08 AM
When I try to iterate it gives error 'TypeError: argument of type 'AdvisoryIOS' is not iterable'
Solved! Go to Solution.
07-30-2019 04:06 AM - edited 07-30-2019 04:07 AM
Hi there,
AdvisoryIOS is an object not a dictionary. You are trying to reference its variables as if they were dictionary keys.
Since the variables are always present in the object you don't need to validate them before adding them to adv_dict. Your code should look like:
advs = []
for adv in advisories: print(adv) adv_dict = dict() adv_dict["cves"] = adv.cves adv_dict["sir"] = adv.sir adv_dict["advisory_id"] = adv.advisory_id adv_dict["advisory_title"] = adv.advisory_title adv_dict["bug_ids"] = adv.bug_ids adv_dict["iosRelease"] = adv.ios_release
advs.append(adv_dict)
return advs
cheers,
Seb.
07-30-2019 07:22 PM
07-30-2019 11:45 PM
Wasn't my answer the solution to this question? ;)
07-30-2019 04:06 AM - edited 07-30-2019 04:07 AM
Hi there,
AdvisoryIOS is an object not a dictionary. You are trying to reference its variables as if they were dictionary keys.
Since the variables are always present in the object you don't need to validate them before adding them to adv_dict. Your code should look like:
advs = []
for adv in advisories: print(adv) adv_dict = dict() adv_dict["cves"] = adv.cves adv_dict["sir"] = adv.sir adv_dict["advisory_id"] = adv.advisory_id adv_dict["advisory_title"] = adv.advisory_title adv_dict["bug_ids"] = adv.bug_ids adv_dict["iosRelease"] = adv.ios_release
advs.append(adv_dict)
return advs
cheers,
Seb.
07-30-2019 07:22 PM
Hi Seb,
Thanks its working...
07-30-2019 11:45 PM
Wasn't my answer the solution to this question? ;)
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide