0

I want to call the function with this two different ways, sharing as parameters strings, numbers and an object with all its possible variable members.

class Coord:
    def __init__(self, x, y):
        self.x = x
        self.y = y

position = Coord(100, 150)

def fu (string, nu1, nu2):
    print(string, nu1, nu2)

def fu (string, po):
    print(string, po.x, po.y)


fu("function called with numbers", 10, 20)
fu("function called with class-object", position)

TypeError: fu() takes 2 positional arguments but 3 were given

georg
  • 211,518
  • 52
  • 313
  • 390
Pablo Lopez
  • 67
  • 2
  • 9

0 Answers0