List &reference to segment of another list. Can dis be done?

Kalle Svensson kalle at lysator.liu.se
Wed May 29 11:56:48 EDT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[Ivan]
> I tried many logical ways to accomplish this (something like this):
> I want to create some list, like:
> 
> >>> li = [0, 1, 2, 4, 8,]
...
> I'd like to have original list changed into [0, 1, 16, 32, 64].

You can use slice assignment.

>>> li = [0, 1, 2, 4, 8]
>>> li[2:] = [16, 32, 64]
>>> li
[0, 1, 16, 32, 64]

Peace,
  Kalle
- -- 
Kalle Svensson, http://www.juckapan.org/~kalle/
Student, root and saint in the Church of Emacs.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.6 <http://mailcrypt.sourceforge.net/>

iD8DBQE89Po4dNeA1787sd0RAhGRAJ9KTK1Ok0QZFrFvQWlICnm+JgrIUQCgjlht
73KUyBSn4EqNWWUU5Ly+POA=
=Ta/I
-----END PGP SIGNATURE-----





More information about the Python-list mailing list