How to accept 0 as a value in a list? and When I enter the numbers after a space I get an error
<p>Everytime I enter a value such as 002
the length comes out as 1 however it should come out as 3
My code is:</p>

<pre><code>list1  = int(input("Enter a number"))
list1 = [int(x) for x in str(list1)]
print (len(list1))
</code></pre>

<p>If I type in a number after a space I get an error saying:</p>

<pre><code>File "C:\\practice11.py", line 2, in &lt;module&gt;
  list1 = [int(x) for x in text]
File "C:\\practice11.py", line 2, in &lt;listcomp&gt;
  list1 = [int(x) for x in text]
</code></pre>

<p>ValueError: invalid literal for int() with base 10: ' '</p>

<p>Don't convert your input to a int. If you convert your the string <code>002</code> to a int, the leading zeros are gone, because <code>002</code> is the same number as <code>2</code>. Converting to string again leads to <code>2</code>, which only has a length of 1.</p>

<pre><code>text  = input("Enter a number")
list1 = [int(x) for x in text]
print(len(list1))
</code></pre>

python