subject

The count_users function recursively counts the amount of users that belong to a group in the company system, by going through each of the members of a group and if one of them is a group, recursively calling the function and counting the members. But it has a bug! Can you spot the problem and fix it?

This is the code :

def count_users(group):
count = 0
for member in get_members(group):
count += 1
if is_group(member):
count += count_users(member)
return count

print(count_users("sales")) # Should be 3
print(count_users("engineering")) # Should be 8
print(count_users("everyone")) # Should be 18

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 16:00
Helen is having a meeting with her colleagues in her company. they are working on the goals and objectives for the coming year. they want to ensure that these goals and objectives of the processes involved are properly evaluated. which system can helen and her colleagues apply to evaluate this? helen and her colleagues require a blank to evaluate the goals and objectives.
Answers: 2
question
Computers and Technology, 25.06.2019 02:30
One important thing in finding employment is to get your resume noticed and read.true or false
Answers: 2
question
Computers and Technology, 25.06.2019 08:00
A( the heart of an information system, is a collection of all relevant facts organized in a series of integrated files.
Answers: 1
question
Computers and Technology, 25.06.2019 08:50
99 points asap ! select the mathematical statement that is true. a.22 % 2 > −3 b.22 % 2 < 5 c.22 % 2 == 4 d.22 % 2 ! = 1 this is for my python coding class you
Answers: 1
You know the right answer?
The count_users function recursively counts the amount of users that belong to a group in the compan...
Questions
question
Mathematics, 21.01.2021 06:00
question
Social Studies, 21.01.2021 06:00
question
Mathematics, 21.01.2021 06:00
question
Mathematics, 21.01.2021 06:00
question
Mathematics, 21.01.2021 06:00
Questions on the website: 13722359