Skip to content

Room 1 - apply_vaccine_py#7

Open
tlestang wants to merge 1 commit intomainfrom
apply_vaccine_py
Open

Room 1 - apply_vaccine_py#7
tlestang wants to merge 1 commit intomainfrom
apply_vaccine_py

Conversation

@tlestang
Copy link
Owner

No description provided.

inject_first_jab(ind)
ndoses = ndoses - 1
else:
raise OutOfDosesException

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what 'raise' does. How is it different from 'print'?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using raise allows me to do stuff like

try:
   # something
except OutOfDosesException:
   # do something else

inject_second_jab(ind)
else:
inject_first_jab(ind)
ndoses = ndoses - 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line should be indented as now ndoses gets reduced by 1 regardless of what happens in the if

def apply_vaccine_to_population(population, ndoses, threshold_age):
for ind in population:
if ndoses > 0:
if (ind["age"] > threshold_age or ind["isAtRisk"]):
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (isEligible(ind)):
   # then do something

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants