Why does this happen?  In [1]: a=[[0]*2]*2 In [2]: a Out[2]: [[0, 0], [0, 0]] In [3]: a[0][0]=1 In [4]: a Out[4]: [[1, 0], [1, 0]]   Shouldn't be?  In [4]: a Out[4]: [[1, 0], [0, 0]]
410
I needed to create a list of lists in Python, so I typed the following: my_list = [[1] * 4] * 3  The list looked like this: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]    Then I changed one of the innermost values: my_list[0][0] = 5  Now my list looks like this: [[5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1]]    which is not what I wanted or expected. Can someone please explain what's going on, and how to get around it?
19795
When I have equations, as in  \begin{equation} ... \end{equation}   Can I arbitrarily assign the numbers to the equations? Instead of the usual order (1), (2), (3), ..., I'd like something like (1), (2.1), (2.2), (2.3), (3.1), (3.2), (4), ...
23996
I am a newbie to Python and have come across the following example in my book that is not explained very well. Here is my print out from the interpreter:  &gt;&gt;&gt; s = 'spam' &gt;&gt;&gt; s[:-1] 'spa'   Why does slicing with no beginning bound and a '-1' return every element except the last one? Is calling s[0:-1] logically the same as calling s[:-1]? They both return the same result. But I'm not sure what python is doing exactly. Any help would be greatly appreciated.
26627
In , it seems that [[:digit:]] = [0-9] = \d.    What are the circumstances where they do not equal? What is the difference?  After some research, I think one difference is that bracket expression [:expr:] is locale dependent.
7764
Why is the following true?  $$\{ \emptyset \}  \neq \emptyset $$  Is it just because the Empty set already refers to there being a set present and so it is just the same argument that $\{ \{3\} \} \neq \{ 3\} $?  And is there a proof for the following?   For any set$\, X$,   $$X \cup \emptyset = X \quad \text{and} \quad X \cap \emptyset = \emptyset$$
41085
Is it generally true that if $|P(A)|=|P(B)|$ then $|A|=|B|$?  Why? Thanks.
2276
A) Specify a bijection from [0,1] to (0,1]. This shows that  |[0,1]|   =  |(0,1]|    B) The Cantor-Bernstein-Schroeder (CBS) theorem says that if there's an injection from A to B and an injection from B to A, then there's a bijection from A to B (ie, |A| = |B|). Use this to come to again show that   |[0;1]| = |(0;1]|
22801
In many languages assignments are legal in conditions. I never understood the reason behind this. Why would you write:  if (var1 = var2) {   ... }   instead of:  var1 = var2; if (var1) {   ... }
26390
Is there an error in this question?  Let u = $(1,0,2)$, v = $(2,1,0)$ and w = $(0,2,1)$. Compute  ||u + v - w.||v = v  This is exactly what is in the question (even the dot after w which I don't know what it means).  Thanks
27093
I occasionally see the list slice syntax used in Python code like this:  newList = oldList[:]   Surely this is just the same as:  newList = oldList   Or am I missing something?
36961
I would like to create something like a=array[1,2,15,6,18] and then a[0]=1, a[1]=2. Is it possible to create an array in LaTeX (with pgf or another package)?
90042
I have been thinking about this problem:  Suppose we have all $R$ by $C$ matrices, where the values are integers in $[1,n]$. Two matrices are equivalent under interchanging rows and columns. For example,   1 5     0 0       would be equal to itself and to  0 0 1 5   and would be equal to  0 0  5 1   and would be equal to   5 1 0 0   How many unique such matrices are there?  Any ideas how to go about it? Any help much appreciated!
18282
I extracted simple example:  require 'pp' x = 1..3 pp x.map do |i| {:value =&gt; i, :double =&gt; (i*2)} end pp x.map { |i| {:value =&gt; i, :double =&gt; (i*2)} }  pp(x.map do |i| {:value =&gt; i, :double =&gt; (i*2)} end) pp(x.map { |i| {:value =&gt; i, :double =&gt; (i*2)} })   I am wondering why first pp produces:  [1, 2, 3]   While all the oders are giving:  [{:value=&gt;1, :double=&gt;2}, {:value=&gt;2, :double=&gt;4}, {:value=&gt;3, :double=&gt;6}]   I assume it has something to do with operator precedence. Where can I find good explanation?
58926
in -> inner  out -> outer / (outter?)  What is the history or set of rules behind why 'inner' doubles the 'n' but 'outer' doesn't double the 't'?
95005
Let $T_n$ be the set of permutations of $\{1,2,\ldots,n\}$ which do not have $i$ immediately followed by $i+1$ for $1\le i\le n-1$; in other words, let \begin{align} T_n=\{\sigma \in S_n: \sigma(i)+1\ne\sigma(i+1) \text{ for all } 1\le i\le n-1\} . \end{align} Let $Q_n$ be the number of elements of $T_n$.    Let $D_n$ be the number of  of $\{1,2,\ldots,n\}$.  It is not hard to show algebraically that $Q_n=D_n+D_{n-1}$, but I am having difficulty coming up with a combinatorial argument to show why this is true.  (I believe there are $D_{n-1}$ elements of $T_n$ that leave $n$ fixed, and $D_n$ elements of $T_n$ that move $n$, but I don't know how to justify this combinatorially.)
28573
I want to make an enumerated list in the following format:  [1] foo foo [2] foo foo ...    How I can do that using enumerated lists? I have tried the following:  \begin{enumerate}[\left[ 1 \right]]   but it does not work.
64886
That's a problem I proved (quite a while back) in tiny Rudin. However, I don't really get it. The other questions were actually useful results - I don't think I've ever come near using this result. Surely it's going to be close to apparent that you're working in an uncountable set?  For instance, examples where this result could be applied but it is hard otherwise to tell that the space is uncountable?