Skip to content

Instantly share code, notes, and snippets.

@bradjohansen
Last active August 26, 2018 03:05
Show Gist options
  • Save bradjohansen/a2d406cc18b98f8fcc2f17927fa043c3 to your computer and use it in GitHub Desktop.
Save bradjohansen/a2d406cc18b98f8fcc2f17927fa043c3 to your computer and use it in GitHub Desktop.
for z in healthPlans.keys():
healthPlanKeys = []
healthPlanKeys.append(z)
print(healthPlanKeys)
i = 0
plans = {}
while i < healthPlans.__len__():
print(healthPlanKeys.__getitem__(i))
plans.__setitem__(healthPlans[healthPlanKeys.__getitem__(i)]['name'], cost)
print(plans)
i = i + 1
@bradjohansen
Copy link
Author

bradjohansen commented Aug 26, 2018

13292
['healthplan1']
['healthplan2']
healthplan2
{'Silver': 13292}
Traceback (most recent call last):
  File "C:/Developer/StephenBradApp/Python/modelMain.py", line 160, in <module>
    cost_comparison(costInput, healthPlanInput)
  File "C:/Developer/StephenBradApp/Python/modelMain.py", line 117, in cost_comparison
    print(healthPlanKeys.__getitem__(i))
IndexError: list index out of range

Process finished with exit code 1`

This is the result. I'm indexing at zero, and yet I only get the second item in the key list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment