Jayeola Akinola
Jayeola Akinola

Reputation: 3

i am trying to run this code as i am practising oop but i getting the error tuple object is not callable

I have made a method in the class which uses a tuple to retrieve two number and find the average and print. i have tried everything i can think of

class Footballer:
    def __init__(self,name,pace):#,physical,shot,passing):
        self.name=name
        self.pace=pace

    def pace(self):
        a,s=self.pace
        pace=int(a)*int(s)*0.5
        print(f" {name}'s pace is {pace}")

pace=(6,7)
leroy=Footballer('Leroy Sane',pace)
leroy.pace()

no error prints 6.5

Upvotes: 0

Views: 29

Answers (1)

brunns
brunns

Reputation: 2764

You have used the name pace as a method name, but then you try and use the same name for a data attribute (self.pace=pace) which overwrites your method. Try using different names.

Upvotes: 1

Related Questions