Function


#1



Hi!
Is len() and .isalpha() both functions?
Cause I didn't understand why I have to specify the len (ex: len(variable) and the .isalpha I just had to put (), without specifying the variable.


if len(original) > 0 and isalpha() :
    print original
else:
    print "empty"


#2

Hi @rhannarr,

You do need to specify the variable with .isalpha(), however the syntax for calling it is different from that of calling the len() function. You should have this ...

if len(original) > 0 and original.isalpha():

len is a function, while isalpha is a type of function known as a method. That is why the syntax for calling them differs. Various upcoming Codecademy exercises explain how methods are distinct from other functions.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.