>>> x=raw_input("Escriba algo: ") Escriba algo: 3489jj0f se0rjwjw0j 0398w3 s2f >>> x '3489jj0f se0rjwjw0j 0398w3 s2f' >>> j=list(x) >>> j ['3', '4', '8', '9', 'j', 'j', '0', 'f', ' ', 's', 'e', '0', 'r', 'j', 'w', 'j', 'w', '0', 'j', ' ', '0', '3', '9', '8', 'w', '3', ' ', 's', '2', 'f'] >>> for i in range(len(j)): ... if j.isdigit(): ... print j ... 3 4 8 9 0 0 0 0 3 9 8 3 2 >>> for i in range(len(j)): ... if j.isdigit(): ... print "j[%s] = %s" % (i,j) ... j[0] = 3 j[1] = 4 j[2] = 8 j[3] = 9 j[6] = 0 j[11] = 0 j[17] = 0 j[20] = 0 j[21] = 3 j[22] = 9 j[23] = 8 j[25] = 3 j[28] = 2 >>> for i in range(len(j)): ... if j.isdigit(): ... digitos+=1 ... >>> print digitos 13
|