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 way to do it by counting the number of occurences of the empty string within the string:
def strlen(s): return s.count('') - 1
Since "".count("") returns 1, you have to subtract 1 to get the string's length.
"".count("")