-
Notifications
You must be signed in to change notification settings - Fork 7
Room 1 - apply_vaccine_py #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| inject_first_jab(ind) | ||
| ndoses = ndoses - 1 | ||
| else: | ||
| raise OutOfDosesException |
There was a problem hiding this comment.
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'?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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"]): |
There was a problem hiding this comment.
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
No description provided.