aint=1077 list_of_aint_as_string=list(str(1077)) print list_of_aint_as_string #['1', '0', '7', '7'] #turn it into a list of integers #doc for map() found on http://docs.python.org/lib/built-in-funcs.html list_of_aint_as_integer=map(int,list_of_aint_as_string) print list_of_aint_as_integer #[1, 0, 7, 7] #or #a list comprehension tutorial found #http://nltk.sourceforge.net/tutorial/advpython/nochunks.html#list_comprehensions list_of_aint_as_integer=[int(x) for x in list_of_aint_as_string] print list_of_aint_as_integer #[1, 0, 7, 7] #now put it into one operation broken_int=map(int,list(str(1077))) print broken_int def return_a_broken_int(aint): return [int(x) for x in list(str(1077))] print return_a_broken_int(aint) #[1, 0, 7, 7]
Now just put what you want or understand into a function and you can use this. HTH kilovh wrote: > I would like to be able to take an integer, break it down into > individual items in a list, and then put them back together. I know > how to do this last part thanks to Orri Ganel and Guillermo Fernandex, > but what about taking the integer apart? > > Sorry if the questions have incredibly obvious answers, I'm new to this. > > ~kilovh > >------------------------------------------------------------------------ > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor > > __________________________________ Do you Yahoo!? Yahoo! Mail - Find what you need with new enhanced search. http://info.mail.yahoo.com/mail_250 _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor