Write a python program as a function which take a string s as input and returns the length of a string s without using the len() method or any other predefined method in python.
You can use a loop to iterate through the characters in the string s and increment a counter variable for each character. Here is a Python function that implements this approach:
def string_length(s): count = 0 for char in s: count += 1 return count
In this function: we takes a string s as an argument and returns the length of the string by counting the number of characters in the string using a loop.
1 thought on “Solution Exercise 59: python program which determines the len of given string”