Can anyone tell me how can I get the length of a string without using the len() function or any string methods. Please anyone tell me as I\'m tapping my head ma
len()
Here's a method which isn't using neither len nor iteration:
len
>>> a = 'a' * 200000 >>> a.rindex(a[-1]) + 1 200000
To make it work for lists, which don't have rindex, use:
rindex
>>> a = list(range(200000)) >>> a.index(a[-1], -1) + 1 200000