Short Story: Why and in what way is the list [2*[0]]*2 different from the list[[0, 0], [0, 0]]?  Long Story:  I was trying to do one of the Python Morsels exercises. Very simply: add all values of the same position in multiple lists of lists. The Example given in the question was:  matrix1 = [[1, -2], [-3, 4]] matrix2 = [[2, -1], [0, -1]] &gt;&gt;&gt; add(matrix1, matrix2) [[3, -3], [-3, 3]]   So I gave it a shot and wrote the following code:  def addmorsel(*inputslists):     addlist = [len(inputslists[0][0])*[0]]*len(inputslists[0])     for listoflists in inputslists:         for i,onelist in enumerate(listoflists):             for j,value in enumerate(onelist):                 addlist[i][j] = addlist[i][j] + value     return addlist   But when I use this function on the example matrices it returns [[0, 0], [0, 0]] instead of the right answer. So I printed the returned addlist to see what happens and apparently the line addlist[i][j] = addlist[i][j] + value seems to add the value to every list within a list instead of only the list it is referencing to.   Replacing the addlist creation line addlist = [len(inputslists[0][0])*[0]]*len(inputslists[0]) by addlist = [[0,0],[0,0]] seems to do the job, but I do not understand why, because that is exactly the same as what addlist becomes by the previous line.   I thought: maybe it references the previous list or something, so I also tried addlist = [2*[0]]*2,so replacing the len() functions by their output, but somehow that also gives the wrong answer.   So my basic understanding of python lists is being shook here.  Why is [2*[0]]*2 different from [[0, 0], [0, 0]]?
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?
When is it best to write "can't" versus writing "cannot"? Are they interchangeable in every situation? How to install the most common plugins? My question is pretty simple.  Since $n! \gt n!!$, it's clear by the comparison test that $\sum_{n=0}^\infty \frac {1}{n!!}$ converges.      But what value does the sum converge to? How does one go about determining its value (if possible)? In my Computer science class I was given a problem where I have to simulate a bouncing ball using "real physics". I have been trying to find a equation that will simulate the height of the bounce given a gravity and an arbitrary mass. And I will need to calculate the next bounce and it's height. A lot of the equations I've found require a time. But I don't really care about a time, all I want is to get the next height after the previous bounce until it finally hits height of 0 or close to it. I haven't taken a physics class since high school( 5 years ago) and that was basic physics. Restoring default toolbar layout in Blender 2.81 A fiber bundle over Euclidean space is trivial. What's the easiest way to see this? The only thing I could think of was to try to patch together trivializations. I couldn't find a way to make that work. Thank you! edit: For the record, here's why I asked about this special case of the more general result about fiber bundles over contractible spaces. In the much beloved book by Bott and Tu, it's claimed that the Leray Hirsch theorem can be proven in the same way the Kunneth theorem is proven:  induct on the size of a finite good cover for the base space, then apply the Mayer Vietoris sequence and the Poincare lemma for the induction step. It's assumed that there exists a finite good cover for the base space, but it's not assumed that this cover is a refinement of the cover of the base space, which gives the local trivializations of the fiber bundle. Therefore, to apply the Poincare lemma in the induction step, it seems that you need to know that the result I asked about is true. Since fiber bundles had just been introduced in the text, I thought there may be a short, elementary proof that the authors had taken for granted. Constructing primitive cell using information from ChemicalData How do I send an HTTP request in C# without using System.Net classes? Need help identifying short story about retired military colonel who fought war at end of time I read this story in an anthology in the eighties or early nineties.  It was about an old man who lived outside a western-like town, though that might have just been how I imagined it.  He goes to town and some ex-military thugs are there causing problems.  Flaunting some odd interdimensional military tech of some sort.  He doesn't want to intervene as doing so would be bad but in the end he must.     By intervening, his military identity is revealed and that causes him (some paradox or causality law) to have to go back and fight the war again.   The war is at the end of time or the universe.  The man is maybe a colonel of the sky something... Not much to go on; I have been searching my collection and wracking my brain for years trying to recall the story. Help with creating a symbolic link I'm confused with how symbolic links work. I hope someone can guide me in the right direction.  I want to put a demo online from our software, which normally only runs locally on a Mac Mini. So I put all the files in the var/www from my Ubuntu 12.04 server installation.  There are a lot of hardcoded links in the software which point to /Applications/XAMPP/xamppfiles/htdocs/narrowcasting  Of course, I could change all these code on my html/php files in /var/www, but that would be quite annoying. I hope I can fix this by creating a symbolic link. For example, I have a directory called thumb in /var/www/thumb. The PHP code is trying to put an image in /Applications/XAMPP/xamppfiles/htdocs/narrowcasting/thumb.   Can anyone give me a tip how to achieve this with a symbolic link? Question  Let $X_n\geq 0$ be independent for $n\geq 1$. The following are equivalent.  $\sum_{n=1}^\infty X_n&lt;\infty$ a.s. $\sum_{n=1}^\infty[P(X_n&gt;1)+E(X_nI(X_n\leq 1)]&lt;\infty$ $\sum_{n=1}^\infty E(X_n/(1+X_n))&lt;\infty$   My attempt I was able to prove $(1)$ implies $(2)$ and $(2)$ implies $(3)$ but not $(3)$ implies $(1)$. For $(1)$ implies $(2)$, observe that by Borel-Cantelli $\sum_{n=1}^\infty P(X_n&gt;1)&lt;\infty$, else $X_n&gt;1$ infinitely often w.p.1 so that $(1)$ is violated. To see that $\sum_{n=1}^\infty E(X_nI(X_n\leq 1)]&lt;\infty$, apply Kolmogorov three-series theorem (I think). For $(2)$ implies $(3)$ we can write that $$ \begin{align} \frac{X_n}{1+X_n}&amp; =\frac{X_n}{1+X_n}I(X_n\leq 1)+\frac{X_n}{1+X_n}I(X_n&gt;1)\\ &amp;\leq X_nI(X_n\leq 1)+ I(X_n&gt;1). \end{align} $$ Now take the expectation of both sides and sum on $n$ using $(2)$ to conclude $(3)$. For the last implication $(3)$ implies $(1)$, I tried to use Kolmogorov three series theorem. To this end put $Y_n=X_nI(X_n\leq 1)$. First note that $\sum_{n=1}^\infty P(X_n&gt;1)&lt;\infty$ since $$ P(X_n&gt;1)\leq P\left(\frac{X_n}{1+X_n}&gt;\frac{1}{2}\right)\leq 2E\frac{X_n}{1+X_n} $$ by Markov's inequality. But I am unable to show that $\sum EY_n&lt;\infty$ and $\sum\text{Var}(Y_n)&lt;\infty$. Any help is appreciated. Show that $x^4-10x^2+1$ is irreducible over $\mathbb{Q}$ In a particular textbook, the work function of a metal (in the context of the photoelectric effect) is defined as:     the minimum amount of energy necessary to remove a free electron from the surface of the metal   This sounds similar to ionisation energy, which is:     the amount of energy required to remove an electron from an atom or molecule in the gaseous state   These two energies are generally different. For instance, Copper has a work function of about 4.7eV but has a higher ionisation energy of about 746kJ mol-1 or 7.7eV.  I've sort of figured it's because the work function deals with free electrons whilst ionisation is done with a valence electron still bound within the atom. Is the difference due to the energy required to overcome the attraction of the positive nucleus? Change color of links created with \in, \at, etc Should 'using' directives be inside or outside the namespace? I have been running  over some C# code, and it keeps reporting that my using directives should be inside the namespace.  Is there a technical reason for putting the using directives inside instead of outside the namespace? When can an autonomous system be written using a Hamiltonian? How to send data to a serial port and see any answer? On Linux, I want to send a command string (i.e. some data) to a serial port (containing control characters), and listen to the response (which also usually might contain control characters).   How can I do this as simplest as possible on Linux? An example is appreciated! Why do professional print houses use gamut-limiting CMYK? I recently had some business cards printed, and was warned to use the CMYK colour space if providing TIF files.  When I tried saving from Paint Shop Pro to a CMYK, of course the colours came out very much duller, so I provided a different file type that preserved my colours using RGB. To my horror, the cards came back nevertheless converted to the CMYK dull shades.    A few months previously I had been in a hurry and had printed my own one-sided quasi business cards using glossy photo paper and a cheap home printer.  This reproduced my desired colours perfectly.  Since the whole point of using professional printers is quality (though I admit bulk as well), why do they not use printers that can cope with the RGB colour range?   FYI: the main colour in question, which I chose very carefully, is a slightly yellow-tinged lawn green, which I understand doesn't feature in the CMYK gamut.  So why use that gamut, and is there anything I can do to overcome this issue and get cards printed in the colour I have chosen? Consider the brief passage:     "I love your work, but calling you 'the artist' {1} just doesn't seem to be   cutting it anymore. What shall I call you?"      "OK. Call me George." {2}   So my instincts tell me to put {1} in single quotes as opposed to no punctuation (or perhaps even italics) but to do the opposite for {2}. Is this right? Why?  Let me expand this one further iteration:     "Wow, that's a great name, especially with this crowd. Maybe for your next book    you should call yourself Ringo."{3} How can I efficiently drive an LED? I understand that I can not connect an LED directly to a battery because it will draw too much current. Thus, there must be something else in the circuit to limit the current. What options are there? Are some methods more efficient than others?