how to append to a list twice?
Sybren Stuvel
sybrenUSE at YOURthirdtower.com.imagination
Fri Apr 21 12:18:15 EDT 2006
John Salerno enlightened us with:
> Interesting. I tried the *2 method twice, but I kept getting weird
> results, I guess because I was using append and not extend. I
> thought extend added lists to lists, but obviously that's not the
> case here.
[100].extend([90]) -> [100, 90]
[100].append([90]) -> [100, [90]]
[100].append(90) -> [100, 90]
Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
More information about the Python-list
mailing list