Dot notation


#1

pi=333
print str(pi)
print len(pi)

‘len() and str() can work on other data types’, this is their explanation. But when I use len method for int it shows an error. Can you tell me why?


#2

we have several data types in python, len() works for multiple data types, but not all. len() does indeed not work for integers, but it work for strings and lists:

len("abc")
len(['a', 'b', 'c'])

#3

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