@Matteo, @Levi, please don't top post it makes following a thread very
difficult, no other comments, TIA.
On 04/07/2012 08:51, Matteo Boscolo wrote:
in the code2
aList=[1,2,3,4,5,6,7,8,9,10]
aList=str(aList) #<--- here you convert the list in a string
print aList
print aList[2] #<-- here you
Yes,you're right.
I got it now.I mistaked that aList also had be changed in code1 before.
Thanks a lot.
2012/7/4 Matteo Boscolo
> in the code2
>
> aList=[1,2,3,4,5,6,7,8,9,10]
> aList=str(aList) #<--- here you convert the list in a string
>
> print aList
> print aList[2] #<-- here you are prin
Yes,you are right.
2012/7/4 Chris Angelico
> On Wed, Jul 4, 2012 at 5:28 PM, levi nie wrote:
> > aList=str(aList)
> > print aList
> > print aList[2]
>
> The str() function takes pretty much anything and returns a string.
> When you subscript a string, you get characters. It's not a list of
> nu
in the code2
aList=[1,2,3,4,5,6,7,8,9,10]
aList=str(aList) #<--- here you convert the list in a string
print aList
print aList[2] #<-- here you are printing the third caracter of the
string '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]' not the list '[1, 2, 3, 4, 5,
6, 7, 8, 9, 10]'
regards
Matteo
Il
On Wed, Jul 4, 2012 at 5:28 PM, levi nie wrote:
> aList=str(aList)
> print aList
> print aList[2]
The str() function takes pretty much anything and returns a string.
When you subscript a string, you get characters. It's not a list of
numbers any more.
(Technically str is a class, not a function,
Hi,Harrison.
Your method is cool.
But i doubt this, if bList and aList just are attached to the same List
when i write bList=aList,but why the output of the following two code are
different?
code1:
aList=[1,2,3,4,5,6,7,8,9,10]
bList=aList
bList=str(bList)
print aList
print aList[2]
code2:
aList=[
You can use :
print "aList is "+repr([x,x,x,x,x,x,x,x,x])
-Shambhu
From: levi nie [mailto:levinie...@gmail.com]
Sent: 04/07/2012 9:43 AM
To: python-list@python.org
Subject: a problem about "print"
aList is a list.i want to get the output seem this "aList is
[x,x,x,x,
On Wed, Jul 4, 2012 at 12:16 AM, levi nie wrote:
> print "aList is "+string(aList) ?
>
>
> 2012/7/4 levi nie
>
>> aList is a list.i want to get the output seem this "aList is
>> [x,x,x,x,x,x,x,x,x]"
>> how can i get this?
>> it's wrong when i write this, print "aList is "+[x,x,x,x,x,x,x,x,x]
>>
print "aList is "+string(aList) ?
2012/7/4 levi nie
> aList is a list.i want to get the output seem this "aList is
> [x,x,x,x,x,x,x,x,x]"
> how can i get this?
> it's wrong when i write this, print "aList is "+[x,x,x,x,x,x,x,x,x]
>
--
http://mail.python.org/mailman/listinfo/python-list
aList is a list.i want to get the output seem this "aList is
[x,x,x,x,x,x,x,x,x]"
how can i get this?
it's wrong when i write this, print "aList is "+[x,x,x,x,x,x,x,x,x]
--
http://mail.python.org/mailman/listinfo/python-list
10 matches
Mail list logo