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
First, convert the integer to a string by using str(), then convert the
string to a list by using list()
--
Message: 6
Date: Mon, 3 Jan 2005 17:17:36 -0500
From: "kilovh" <[EMAIL PROTECTED]>
Subject: [Tutor] Breaking down integers?
To:
Message-ID: &
0,size1)])decimal=sum([float(lista[lista.index('.')+i])*10**(-i) for i
in range(1,size2+1)])a2=sign*(integer+decimal)print 'The number is
packed again:',a2
- Original Message -
From:
kilovh
To: tutor@python.org
Sent: Tuesday, January 04, 200
On Mon, 03 Jan 2005 17:41:49 -0500, Brian van den Broek
<[EMAIL PROTECTED]> wrote:
> .>>> an_int_as_string_list = list(an_int_as_string)
> .>>> print an_int_as_string_list
> ['4', '2']
*Smacks head with palm* Of course, you're right . . . no need to go
into ' '.join(str(x)).split() . . . Python's
kilovh said unto the world upon 2005-01-03 17:17:
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
On Mon, 3 Jan 2005 17:17:36 -0500, kilovh <[EMAIL PROTECTED]> 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 tak
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