3
u/Luigi-Was-Right Aug 29 '25
Is it possible you are using spaces and tabs together? There is a shortcut to convert all indents to tabs (or spaces, depending on your preference). If that's not the issue, can you share the error message verbatim?
1
1
u/echols021 Aug 29 '25
return user_groups should be one level to the left of where it is shown in this image.
Where it currently is, your outer for-loop will only ever look at the first item, since the return will completely leave the function before it gets to the 2nd run of that outer for-loop.
If you move return user_groups one level to the left so it is outside both for-loops, then your outer loop will do all its stuff and finish first before the return statement is reached.
1
u/program_kid Aug 29 '25
I have a feeling you are mixing tabs and spaces. I typed out your code line for line on my machine and I didn't get the error so I'm assuming that you have a mixture of tabs and spaces in your code.
1
u/BranchLatter4294 Aug 30 '25
Those vertical lines are there for a reason. Pay attention to them. Let them be your guide.

4
u/shudaoxin Aug 29 '25
You declared it in line 2. You want to return it in the same scope (4 spaces back)