Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I print a list from a class in python?

Ive done C++ classes now im learning Python so the classes are new to me. Im trying to simply do some experimenting. I have created two for loops to create every possible combination of fpok from size 1 to 9. However, how do I print the outputs? In other words how do I print the list possibleStringList from this class?

import itertools

class TestClass:
    def __init__(self):
        self.possibleStringList = []
        self.possibleStringList.append("")
        
        for i in range(1, 9):
            for str in itertools.product("fpok", repeat=i):
                self.possibleStringList.append(str)

Thank you.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use the print function.

test_class = TestClass()
print(test_class.possibleStringList)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading