Hi Jim,
When you replace num = int(num); it's not changing a list.
Due to It only pick a value from a list.
You have to pointing to list so,
You have to use list[position] using while loop like below

listOfNumChars = list(str(intNum))
i = 0
while i < len(listOfNumChars):
        listOfNumChars[i] = int(listOfNumChars[i])
        i += 1

print(listOfNumChars)

#--> [4, 5, 5] (if you entered 455)


Best,
Bhanu Pratap


-----Original Message-----
From: Tutor [mailto:tutor-bounces+bhanubais=gmail....@python.org] On Behalf Of 
Jim Mooney
Sent: Saturday, May 04, 2013 9:43 AM
To: tutor@python.org
Subject: [Tutor] changing char list to int list isn't working

I'm turning an integer into a string so I can make a list of separate chars, 
then turn those chars back into individual ints, but the resulting list still 
looks like string chars when I print it. What am I doing wrong?


listOfNumChars = list(str(intNum))
for num in listOfNumChars:
    num = int(num)

print(listOfNumChars)

# result of 455 entered is ['4', '5', '5']

--
Jim Mooney

“For anything that matters, the timing is never quite right, the resources are 
always a little short, and the people who affect the outcome are always 
ambivalent.”
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to