Python Doubt | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python Doubt

I was doing some experiements while writing a code. To my surprise I found something strange result. I know the code is wrong but it was just my curiosity to experiement it. https://code.sololearn.com/cuMBIxY38QvN/?ref=app

5th Jan 2022, 5:55 PM
<k>Kartik</k>
3 Answers
+ 2
Your code is not wrong. In Python functions are objects, so you are able to print them. So you see the name and the memory address of isalnum() For more details you can read this article: https://www.journaldev.com/22460/python-str-repr-functions
5th Jan 2022, 6:15 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
If you are looking for the value True or False don't forget to add ( ) to your method. print(name.isalnum()) will return True
5th Jan 2022, 9:03 PM
YoPycode
0
What's the problem ? It's a function object, executed with parentheses name="kartik" print(name.isalnum) help(name.isalnum) print("\n".join([x for x in dir(name)]))
5th Jan 2022, 6:16 PM
FanYu
FanYu - avatar