Need help understanding this code about recursion in python
Hi! I'm doing an online course aside the coursera ones about python. In a practice quiz i got this problem: 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? 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 And i had to fix it so the results were 3, 8 and 18 respectively given those parameters I just went and moved the count += 1 as an else: statement because i felt it was counting all users even if they were not on a group and it looked like this and reurned all answers as requested: def count_users(group): count = 0 for member in get_members(group): if is_group(member): count += count_users(member) else: count += 1 return count print(count_users("sales")) # Returned 3 as requested print(count_users("engineering")) # Returned 8 as requested print(count_users("everyone")) # Returned 18 as requested My problem is that i don't understand a lot from that script 1) It only runs on the practice quiz interpreter, i tend to edit and run my exercises in vscode for review purposes but it doesn't run because get_members is not defined. 2) I don't understand where that get_members(group) came from 3) How the program knows that "sales", "engineering" and "everyone" has those values? Can someone give me a step by step explanation? Thanks :)