[Answered ]-Initiating a method in a class

2👍

Good news – it’s a simple one! To call other() on create, you’d do this:

list = [3, 4, 5]
y = Create(list)
y.other('one')

You just need to pass the parameters inside the parentheses, after the name of the method.

EDIT: I’ve just noticed you want to call other from inside the Create class. That’d look like this:

class Create:
    def __init__(self, something):
        self.test = something[1]
        self.other(123)

    def other(self, one):
        self.two = one

It’s also worth bearing in mind that self.two won’t exist when you get to the other() method.

Leave a comment