Dot notation


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?


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(['a', 'b', 'c'])


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