use of index (beginner's question)

Chris Rebert clp2 at rebertia.com
Wed Apr 27 21:39:14 EDT 2011


On Wed, Apr 27, 2011 at 6:23 PM, Thomas 'PointedEars' Lahn
<PointedEars at web.de> wrote:
> Chris Angelico wrote:
>> Rusty Scalf wrote:
>>> list1 = ['pig', 'horse', 'moose']
>>> list2 =  ['62327', '49123', '79115']
>>> n = 2
>>> s2 = "list" + `n`
>> I would prefer the clearer
>>  s2 = "list" + str(n)
>> or
>>  s2 = "list%s" % n

Agreed. The backticks operator is deprecated and was removed in Python 3.
Cheers,
Chris


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /