Re: Problem with lists

2015-09-16 Thread Rafael David
Em terça-feira, 15 de setembro de 2015 21:47:10 UTC-3, Chris Angelico escreveu: > On Wed, Sep 16, 2015 at 10:29 AM, Rafael David wrote: > > Oooohhh ... I think I got it! I'm assigning a reference to peca and not the > > value itself! Thank you very much MRAB and C Smith for the enlightenment :)

Re: Problem with lists

2015-09-15 Thread Chris Angelico
On Wed, Sep 16, 2015 at 10:29 AM, Rafael David wrote: > Oooohhh ... I think I got it! I'm assigning a reference to peca and not the > value itself! Thank you very much MRAB and C Smith for the enlightenment :) Right! That's how Python's assignment always works. You may find, in your case, that y

Re: Problem with lists

2015-09-15 Thread Rafael David
Em terça-feira, 15 de setembro de 2015 21:11:38 UTC-3, MRAB escreveu: > On 2015-09-16 00:45, Rafael David wrote: > > Hi guys, > > > > I'm newbie in Python (but not a newbie developer). I'm facing a > > problem with a bidimensional list (list of lists) containing > > dictionaries. I don't know if I

Re: Problem with lists

2015-09-15 Thread MRAB
On 2015-09-16 00:45, Rafael David wrote: Hi guys, I'm newbie in Python (but not a newbie developer). I'm facing a problem with a bidimensional list (list of lists) containing dictionaries. I don't know if I didn't understand how lists and dictionaries work in Python or if there is a mistake in m

Re: Problem with lists

2015-09-15 Thread C Smith
>>tabuleiro[lin][col] = peca use peca.copy() here or else a deep copy is made. On Tue, Sep 15, 2015 at 4:45 PM, Rafael David wrote: > Hi guys, > > I'm newbie in Python (but not a newbie developer). I'm facing a problem with > a bidimensional list (list of lists) containing dictionaries. I don't

Problem with lists

2015-09-15 Thread Rafael David
Hi guys, I'm newbie in Python (but not a newbie developer). I'm facing a problem with a bidimensional list (list of lists) containing dictionaries. I don't know if I didn't understand how lists and dictionaries work in Python or if there is a mistake in my code that I can't see. In the code I'm

Re: Problem with lists.

2009-02-22 Thread Matimus
On Feb 20, 8:12 am, "ssd" wrote: > Hi, > > In the following code, (in Python 2.5) > I was expecting to get in "b" variable the values  b: [[0, 0], [0, 1],[0, > 2], [0, 3],[0, 4], [1, 0],[1, 1], [1, 2], .] > But I get only the last value [4,4], b: b: [[4, 4], [4, 4], [4, 4], ... ] > > My code:

Re: Problem with lists.

2009-02-22 Thread Chris Rebert
On Fri, Feb 20, 2009 at 8:12 AM, ssd wrote: > > Hi, > > In the following code, (in Python 2.5) > I was expecting to get in "b" variable the values b: [[0, 0], [0, 1],[0, > 2], [0, 3],[0, 4], [1, 0],[1, 1], [1, 2], .] > But I get only the last value [4,4], b: b: [[4, 4], [4, 4], [4, 4], ... ]

Re: Problem with lists.

2009-02-22 Thread des...@gmail.com
On Feb 20, 10:12 am, "ssd" wrote: > Hi, > > In the following code, (in Python 2.5) > I was expecting to get in "b" variable the values  b: [[0, 0], [0, 1],[0, > 2], [0, 3],[0, 4], [1, 0],[1, 1], [1, 2], .] > But I get only the last value [4,4], b: b: [[4, 4], [4, 4], [4, 4], ... ] > > My code:

Problem with lists.

2009-02-22 Thread ssd
Hi, In the following code, (in Python 2.5) I was expecting to get in "b" variable the values b: [[0, 0], [0, 1],[0, 2], [0, 3],[0, 4], [1, 0],[1, 1], [1, 2], .] But I get only the last value [4,4], b: b: [[4, 4], [4, 4], [4, 4], ... ] My code: a = ["",""] b = [] for i in range (0,5):

Re: simple problem with lists I am just forgetting

2008-07-31 Thread Paul McGuire
On Jul 31, 2:51 pm, Alexnb <[EMAIL PROTECTED]> wrote: > Lets say we have this list: > > funlist = ['a', 'b', 'c'] > > and lets say I do this: > > if funlist[4]: >     print funlist[4] > > I will get the exception "list index out of range" > > How can I test if the list item is empty without getting

Re: simple problem with lists I am just forgetting

2008-07-31 Thread bearophileHUGS
Alexnb: > How can I test if the list item is empty without getting that exception? In Python such list cell isn't empty, it's absent. So you can use len(somelist) to see how much long the list is before accessing its items. Often you can iterate on the list with a for, so you don't need to care of

simple problem with lists I am just forgetting

2008-07-31 Thread Alexnb
-- View this message in context: http://www.nabble.com/simple-problem-with-lists-I-am-just-forgetting-tp18762181p18762181.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list