Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

print is returning an address instead of a value

I’m new to python and i’m trying to print this function but it just shows the address of the function.

def eligible(age, lingo, language):
    return "Eligible!" if(int(age) in range(25, 46)) and (lingo=='ingles') and (language=='python') else "Not Eligible!"

age=input("What's your age?: ")
language=input("What language do you speak?: ")
planguage=input("What programing language do you use?: ")
eligible(age, language, planguage)

print(eligible)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In Python anything is an object, this includes functions.
When you print a function, you get the address of that function.

As you want your eligible function to return a string, you need to store the result in a variable or put the function call inside your print function:

res = eligible(age, language, planguage)
print(res)
print(eligible(age, language, planguage))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading