An overdue Thank You to everyone who responded. I got well more than I
bargained for, including needed reinforcement (beyond the beginner's
guides) of how Python actually works and some good programming habits. I
am grateful.
I liked Steven D'Aprano comment:
Define does not work.
What
On Apr 28, 2:45 am, Chris Angelico ros...@gmail.com wrote:
Incidentally, you're allowed to put the comma on the last item too:
lists = [
['pig', 'horse', 'moose'],
['62327', '49123', '79115'],
]
Often makes for easier maintenance, especially when you append
array/list elements.
On Apr 28, 5:32 am, Algis Kabaila akaba...@pcug.org.au wrote:
On Thursday 28 April 2011 11:23:51 Thomas 'PointedEars' Lahn
wrote: Chris Angelico wrote:
Rusty Scalf wrote:
list1 = ['pig', 'horse', 'moose']
list2 = ['62327', '49123', '79115']
n = 2
s2 = list + `n`
list + 'n'
(Peter Otten)
5. Re: Access violation reading 0x0010 (yuan zheng)
6. Re: argparse parser stores lists instead of strings (Peter Otten)
7. Re: use of index (beginner's question) (Iain King)
8. Re: argparse parser stores lists instead of strings
(Gabriel Genellina)
9. Re: Access
On Thu, 28 Apr 2011 01:49:33 +0100, Chris Angelico ros...@gmail.com
wrote:
On Thu, Apr 28, 2011 at 10:42 AM, Rusty Scalf iai-...@sonic.net wrote:
list1 = ['pig', 'horse', 'moose']
list2 = ['62327', '49123', '79115']
n = 2
s2 = list + `n`
a = s2[list1.index('horse')]
print a
s2 is a string
On Thu, Apr 28, 2011 at 11:42 AM, Rusty Scalf iai-...@sonic.net wrote:
list1 = ['pig', 'horse', 'moose']
list2 = ['62327', '49123', '79115']
n = 2
s2 = list + `n`
a = s2[list1.index('horse')]
print a
-does not work
While advices above are indeed right way to go in your case, there is
a
On Thu, Apr 28, 2011 at 10:42 AM, Rusty Scalf iai-...@sonic.net wrote:
list1 = ['pig', 'horse', 'moose']
list2 = ['62327', '49123', '79115']
n = 2
s2 = list + `n`
a = s2[list1.index('horse')]
print a
s2 is a string with the value list2; this is not the same as the
variable list2. You could
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
a = s2[list1.index('horse')]
print a
s2 is a string with the value list2; this
On Wed, Apr 27, 2011 at 6:23 PM, Thomas 'PointedEars' Lahn
pointede...@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 %
On Thu, Apr 28, 2011 at 11:23 AM, Thomas 'PointedEars' Lahn
pointede...@web.de wrote:
You forgot a comma after the first `]', to separate the list elements.
Whoops! Apologies. It's very confusing when example code has silly
bugs in it! And yes, need to either back down the indices or insert a
On Wed, 27 Apr 2011 17:42:30 -0700, Rusty Scalf wrote:
Greetings,
I am just now learning python and am trying to use the index function
with variables.
list1 = ['pig', 'horse', 'moose']
list2 = ['62327', '49123', '79115']
a = list2[list1.index('horse')]
print a
49123
-works
On Thursday 28 April 2011 11:23:51 Thomas 'PointedEars' Lahn
wrote:
Chris Angelico wrote:
Rusty Scalf wrote:
list1 = ['pig', 'horse', 'moose']
list2 = ['62327', '49123', '79115']
n = 2
s2 = list + `n`
list + 'n'
'listn'
And IMHO you did not want that, did you?
OldAl.
--
Algis
12 matches
Mail list logo