How come modulo will help in dividing the team?

Hi
I was doing the 10th lesson of the live stream.
Here is the URL -https://www.codecademy.com/courses/livestreams/lessons/learn-python-syntax/exercises/modulo?action=resume_content_item.

I want to know that how modulo help in dividing the group into 4 teams?
THANK YOU

lets say we loop from 1 till 28, then 1 % 4 will give one (so we can put that person in team 1), 2 % 4 will give 2 (so we can put that person in team 2) and so forth (3 % 4 = 3, 4 % 4 = 0, 5 % 4 = 1)

the only tricky bit is numbers divisible by 4 (given that gives zero, you can put those people in team 4 with simple conditional check), but that can be overcome

1 Like