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

Looks to me like a bit of a hack.
A ā€œmickey mouseā€ solution.
Lets ā€˜fix it with duct tapeā€™ to make it work cuz we canā€™t figure out any other way right now.
IMHO.