Answers for "bar() takes 3 positional arguments but 4 were given"

0

takes 2 positional arguments but 3 were given

# just put self in other functions like this
class myclass:
  def __init__(self, parameter):
  	self.parameter = parameter
  def function(self, otherparameter):
    # put a self ^ there
    print(self.parameter + otherparameter)

object=myclass(1)
object.function(2)
# output is 3
Posted by: Guest on January-12-2021
1

2 positional arguments but 3 were given

#Positional arguments are the amount of arguments passed through a function
#For example

def function(value1, value2):
	print(value1)
	print(value2)

function("value1","value2","value3")
Posted by: Guest on October-21-2020

Code answers related to "bar() takes 3 positional arguments but 4 were given"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language