-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Solution1 #1236
base: master
Are you sure you want to change the base?
Solution1 #1236
Conversation
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.
Great job on implementing the solution! 🎉 Your code meets the task requirements and constraints effectively. While there are some minor improvements suggested, such as removing the unnecessary flag
variable and adding more descriptive messages when raising exceptions, these do not impact the core functionality of your code. Keep up the good work and consider these suggestions for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
flag = True | ||
if "vaccine" not in visitors.keys(): | ||
flag = False | ||
raise NotVaccinatedError |
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.
The NotVaccinatedError
should be raised with a descriptive message as per the checklist requirement. Consider using: raise NotVaccinatedError('Visitor is not vaccinated.')
.
expiration_date = visitors["vaccine"]["expiration_date"] | ||
if expiration_date < today: | ||
flag = False | ||
raise OutdatedVaccineError |
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.
The OutdatedVaccineError
should be raised with a descriptive message. Consider using: raise OutdatedVaccineError('Visitor's vaccine is outdated.')
.
mask = visitors.get("wearing_a_mask") | ||
if not mask: | ||
flag = False | ||
raise NotWearingMaskError |
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.
The NotWearingMaskError
should be raised with a descriptive message. Consider using: raise NotWearingMaskError('Visitor is not wearing a mask.')
.
flag = True | ||
if "vaccine" not in visitors.keys(): | ||
flag = False | ||
raise NotVaccinatedError | ||
today = datetime.date.today() | ||
expiration_date = visitors["vaccine"]["expiration_date"] | ||
if expiration_date < today: | ||
flag = False | ||
raise OutdatedVaccineError | ||
mask = visitors.get("wearing_a_mask") | ||
if not mask: | ||
flag = False | ||
raise NotWearingMaskError | ||
if flag: | ||
return f"Welcome to {self.name}" |
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.
The flag
variable is unnecessary. The function can directly raise exceptions or return the welcome message without using this variable.
flag = True | ||
for friend in friends: | ||
try: | ||
cafe.visit_cafe(friend) | ||
except VaccineError: | ||
flag = False | ||
return "All friends should be vaccinated" | ||
except NotWearingMaskError: | ||
counter_masks += 1 | ||
if counter_masks > 0: | ||
return f"Friends should buy {counter_masks} masks" | ||
if flag: | ||
return f"Friends can go to {cafe.name}" |
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.
The flag
variable is unnecessary. The function can directly return the appropriate message after checking conditions without using this variable.
No description provided.