Skip to content
Advertisement

How can I pass a list from one class to another?

I’m still pretty new to python so, as said in the title, I’m trying to pass a list from inside one class to another class.

For example:

JavaScript

As shown in the example I want a list from class one to be passed to class two so that it can then be used (printed in the example).

Advertisement

Answer

You should make list_wanting_to_be_passed an instance attribute so that you can keep a reference to it:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement