[Solved] Separate a number into its digits and work with each digit


z is a list so you can access each element :

>>> n = input()    
19894984
>>> z=[int(d) for d in str(n)]
>>> z
[1, 9, 8, 9, 4, 9, 8, 4]
>>> a=z[0]
>>> a
1
>>> a=z[5]
>>> a
9

and iterate trough it :

>>> for i in z:
...     print i
... 
1
9
8
9
4
9
8
4
>>> for i in range(len(z)):
...     print z[i]
... 
1
9
8
9
4
9
8
4

or directly do operation to have a new list :

>>> z2=[i*2 for i in z]
>>> z2
[2, 18, 16, 18, 8, 18, 16, 8]

0

solved Separate a number into its digits and work with each digit