Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99988

Is there a way to set several list elements a same value with one line code

X-Received by 10.67.5.169 with SMTP id cn9mr11146802pad.0.1449189025947; Thu, 03 Dec 2015 16:30:25 -0800 (PST)
X-Received by 10.50.66.229 with SMTP id i5mr57859igt.10.1449189025874; Thu, 03 Dec 2015 16:30:25 -0800 (PST)
Path csiph.com!xmission!news.glorb.com!mv3no11216783igc.0!news-out.google.com!f6ni16143igq.0!nntp.google.com!mv3no11216774igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Thu, 3 Dec 2015 16:30:25 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=50.100.117.144; posting-account=SZ_svQkAAACWRFG2bDA-zgq8ILyl4-vo
NNTP-Posting-Host 50.100.117.144
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <d8efbad4-43d9-49ef-b0a9-dec1df52b3ab@googlegroups.com> (permalink)
Subject Is there a way to set several list elements a same value with one line code
From Robert <rxjwg98@gmail.com>
Injection-Date Fri, 04 Dec 2015 00:30:25 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:99988

Show key headers only | View raw


Hi,

I remember that there is a way to set several list elements a same value with
 one line code. Excuse me, I don't remember the accurate syntax on the code
 snippet. But the basic format looks like this.

1. There is a four-element list, such as: 
   bb=[[[]],[[]],[[]],[[]]]
2. An assignment line is here:
   bb[0]='a'
3. Then, all 4 element of bb is set with the above value.
   bb=[['a'],['a'],['a'],['a']]

The above three line codes are what I guess (I forgot the original tutorial
 now). Do you remember there is such a list application?


Thanks,

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Is there a way to set several list elements a same value with one line code Robert <rxjwg98@gmail.com> - 2015-12-03 16:30 -0800
  Re: Is there a way to set several list elements a same value with one line code MRAB <python@mrabarnett.plus.com> - 2015-12-04 00:58 +0000
    Re: Is there a way to set several list elements a same value with one line code Robert <rxjwg98@gmail.com> - 2015-12-03 18:11 -0800
  Re: Is there a way to set several list elements a same value with one line code Denis McMahon <denismfmcmahon@gmail.com> - 2015-12-04 04:19 +0000

csiph-web