Re: a problem about "print"

2012-07-04 Thread Mark Lawrence
@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

Re: a problem about "print"

2012-07-04 Thread levi nie
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

Re: a problem about "print"

2012-07-04 Thread levi nie
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

Re: a problem about "print"

2012-07-04 Thread 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 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

Re: a problem about "print"

2012-07-04 Thread 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 numbers any more. (Technically str is a class, not a function,

Re: a problem about "print"

2012-07-04 Thread levi nie
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=[

RE: a problem about "print"

2012-07-03 Thread Shambhu Rajak
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,

Re: a problem about "print"

2012-07-03 Thread Harrison Morgan
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] >>

Re: a problem about "print"

2012-07-03 Thread levi nie
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

a problem about "print"

2012-07-03 Thread 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