Skip to content

Conversation

@sheida-shab
Copy link

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

@sheida-shab sheida-shab added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Tools The name of the module. labels Dec 7, 2025
@OracPrime OracPrime added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jan 6, 2026
Copy link

@OracPrime OracPrime left a comment

Choose a reason for hiding this comment

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

Generally solid code, but a couple of bits need tidying up or clarifying.

.gitignore Outdated
@@ -1 +1,2 @@
node_modules
implement-cowsay/.venv

Choose a reason for hiding this comment

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

I'm guessing this line is left over from a previous exercise!

Copy link
Author

Choose a reason for hiding this comment

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

Yes, you’re right! This line is leftover from the previous cowsay exercise. I’m keeping it intentionally because the virtual environment is still needed there. I’ve added a comment in .gitignore to make this clear.

]

# Global sadness counter
sadness=0

Choose a reason for hiding this comment

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

Having a global variable is normally a bad idea. This could just as easily be created inside the allocate_laptops function and returned as part of a multi-value return from the function. As it is if you call the function twice the second time will include the sadness from the first time in its sadness score.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your feedback.
I fixed it.

if person.preferred_operating_system[i] == laptop.operating_system :
allocated_history[person.name]=laptop # assign laptop
sadness += i # increment sadness by preference index
laptops.remove(laptop)

Choose a reason for hiding this comment

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

The laptops argument is passed to allocate_laptops by reference. So this remove function is modifying the original list of laptops. Now this may be intentional, in which case it should be made obvious somewhere. Alternatively make a copy of the list at the start of the function and modify that inside the function. I can see arguments for both approaches being desirable, but it would be good to make it obvious.

Copy link
Author

@sheida-shab sheida-shab Jan 7, 2026

Choose a reason for hiding this comment

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

Yhank you for your comment.
Laptops list is modified on purpose.
After allocation, it shows the laptops that are still left.I fixed it.
I added a comment for clarify this.

break

if not allocated_flag : # assign any remaining laptop if preferred OS not found
allocated_history[person.name]=laptops[0]

Choose a reason for hiding this comment

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

Both here and above you're using person.name as they key in the dictionary. On line 53 you declared the key as Person. One or the other needs correcting.

Copy link
Author

Choose a reason for hiding this comment

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

I fixed it.

@OracPrime OracPrime added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jan 6, 2026
@sheida-shab sheida-shab added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Jan 7, 2026
@OracPrime OracPrime added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jan 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Tools The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants