Home > Mobile >  How do I print a list from a class in python?
How do I print a list from a class in python?

Time:02-17

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.

CodePudding user response:

Use the print function.

test_class = TestClass()
print(test_class.possibleStringList)
  • Related