Can I have more than one function with the same name?

It looks like we have to compare both strings in the if statements.

I have a question. it is true that I can have functions with the same name but that they have a different parameter in the ().
For example
def the_function():

some statement

def the_function(name):
#some statement

these functions have the same name but they are different for the compiler true ?? this methodology is called
overloaded (In java this thing is possible if I remember well)

tranks for your answer

Function overloading involves having one function that has no parameters, and one function that takes an object. If they have the same name, the interpreter/compiler will choose based on parameter.

tranks for your answer

1 Like

Function overloading is a thing but I’m not aware of such an option being possible in Python.

Had to nose into it as I’m sure I’ve come across pythonic solutions to this before, other than just trying to squeeze in different chunks of code based on conditionals. Turns out there’s quite a few options so for anyone who really wants to mimic function overloading there’s plenty of discussion at-

1 Like