Having trouble with imported items in course
Script.py is not recognizing an object from classroom_organizer.py after importing.
on assignment number 4

4:“Next, we need to organize our classroom and decide where our students will be sitting. We have 5 tables in our classroom that can seat 2 students each. We’d like to see what combination of students we can put at each table.
Using the itertools module, define a method within ClassroomOrganizer that will retrieve a final list of all tuple combinations of 2 students that can be seated at each table.
From script.py, print out the result to see all the possible combinations.”

current issue is that script.py is saying “two_students” is not defined when it is defined in ClassroomOrganizer.py did I import it incorrectly?

I just tried adding global above “two_students” still getting not defined.

Also your comment " Also, I don’t see that function perTable() called anywhere.
I assume its a static method: ClassroomOrganizer.perTable()" doesn’t make sense to me? I don’t see why it would need to be called/

I checked … global does not work here because it can only access a variable, but not modify it (in this case).

The function per_table needs to be called because the code in the function won’t run otherwise. (It’ll compile, but it won’t get executed.)

Also, if you want to get the contents of that variable two_students from the function, you may want to return it (or some version of it) or just have the print inside the function.

Sure, you can do that as a function,
but the function call math_and_science()
or ClassroomOrganizer.math_and_science() (if the function is in that class)
would be in script.py

print( ClassroomOrganizer.math_and_science() )

Don’t forget the other 2 lines that go before chained_iterables:

math = class1.get_students_with_subject("Math")
science = class1.get_students_with_subject("Science")

Sorry to ask yet another question, but you say that the function call will be in script.py. I tried this giving undefined again it also is not apart of the class. Also could you explain:

math = class1.get_students_with_subject(“Math”)
science = class1.get_students_with_subject(“Science”)

Not seeing why this would be required as math and science are already listed within the roster.py list.

In my version, there wasn’t a math nor science variable in roster.py, so I had to set those up. (I may have an older version of the project.)

There is a get_students_with_subject method for ClassroomOrganizer objects.
I can make a ClassroomOrganizer object, and put it as variable class1 by doing the code below, maybe in script.py:

class1 = classroom_organizer.ClassroomOrganizer()

and at some point after that:

math = class1.get_students_with_subject("Math")
science = class1.get_students_with_subject("Science")

If you already have math and science variables, then you don’t have to do that, I guess.