how to find the length of a list in python without using len()
<p>I want to write a function which will find out the length of a list based on user input. I don't want to use the in-built function <code>len()</code>.</p>
<p>Function which i have written is working for strings but for lists it is failing.</p>
<pre><code>#function for finding out the length
def string_length(a):
    for i in a:
        j+=1
    return j

#taking user input
a = input(&quot;enter string :&quot;)
length = string_length(a)
print(&quot;length is &quot;, length)
</code></pre>