I have written a python code, to solve a puzzle. It was not working as expected. So while debugging I saw something very weird. Row is a list of lists. The append 1 to single row[n] appends to all lists inside row!   def trap( height):         row = []          for index, i in enumerate(height):             if i == 0 and len(row) == 0:                 continue             else:                 if(i &gt; len(row)):#time for a new row                   #to old rows append 0 below                     for j in range(0, len(row)):                         row[j].append(0)                   row = row + [[0]] * (i - len(row))                             else:                   for j in range(0,i):                      row[j].append(0)                   #PROBLEMATIC CODE START                     for jo in range(i,len(row)):                         if(index == 1):                             print("jays are",row)                             print("jo is",jo, row[jo])                         row[jo].append(1)                   #PROBLEMATIC CODE END (I GUESS?)           print(row) #print this, it gives an idea   trap([2,0])   When I try this independently, it works fine, see:  row = [[0],[0]] index = 1  for jo in range(0,len(row)):       if(index == 1):                   print("jays are",row)                   print("jo is",jo, row[jo])                   row[jo].append(1) print(row)    The problematic code has been marked in the python as comment #PROBLEMATIC CODE START and #PROBLEMATIC CODE END. Call the trap() with [2,0]  row variable should be [[0,1],[0,1]] but row variable is coming [[0,1,1],[0,1,1]]  I have been at this for many hours! I just don't understand why does .append() appends to all the lists inside row, but when I try the smaller code it works. Please help me and guide me
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?
Arrows describing matrix Lets say I have a 5x5 matrix. I want to place 2 leftrightarrows (with descriptions "3", "2") underneath the matrix, but really close to it: first pointing from col1 to col3 and second from col4 to col5. Plus updownarrows with similar outcome. How can I achieve that?  draft:  1 1 1 | 1 1  &lt;--> &lt;-> List all the directories under the current one I'm trying to remember the name of a series of books about a boy who works with dragons.  Dragon's blood (or maybe it was slobber?) is acidic, and the children who wrangle these dragons often end up with deep pock marks.  On this world, days are like ours but nights get very cold, requiring anyone stuck outside to find a shelter until dawn (not the false dawn)  The other thing I remember is that in one of the books by slicing open a dragon and spending the night, the character emerged with special dragon powers. The units of $\mathbb Z[\sqrt{2}]$ Zooming / Focusing certain parts of a chart in latex I am using pgfplot to draw graphs in latex. Now this is the problem I am facing:  \begin{tikzpicture}[scale=1] \begin{axis}[ybar,grid=major,bar width=2pt,width=8cm, height=8cm,xmin=1,xmax=540,ymin=1,ymax=240] \addplot [draw=black,fill=green]  table [x=size, y=cluster, col sep=comma] {sim-0.4-0.6.csv}; \end{axis} \end{tikzpicture}   It generates the following graph:    Since, I have values mainly between 0-50 on x-axis, I want to zoom there. After that, values comes around 500. S0, there are no graph points between 50 - 450. How should I do that? Is my way of solving and my answer correct?  Let $f(x)=x+\frac{x^2}{2}+\frac{x^3}{3}+\frac{x^4}{4}+\frac{x^5}{5}$   And $g(x)=f^{-1}(x)$  Find $g'''(0)$  My attempt:  We know that $g'(x)=\frac{1}{f'(g(x))}$  $f'(x)=1+x+x^2+x^3+x^4=\frac{x^5-1}{x-1}$  $f'(g(x))=\frac{(g(x))^5-1}{(g(x))-1}$  $\Rightarrow g'(x)=\frac{(g(x))-1}{(g(x))^5-1}$  $\Rightarrow g'(x)[(g(x))^5-1]=g(x)-1$  Similarly differentiating again,  $\Rightarrow g'(x)[5(g(x))^4]+[(g(x))^5-1]g''(x)=g'(x)$  Similarly differentiating again,  $\Rightarrow g'(x)[20(g(x))^3g'(x)]+[5(g(x))^4]g''(x)+[(g(x))^5-1]g'''(x)+g''(x)[5(g(x))^4]=g''(x)$  Putting $x=0$,  $g(0)=f^{-1}(0)=0$  $g'(0)=\frac{1}{f'(g(0))}=\frac{1}{f'(0)}=1$  similarly,$g''(0)=-1$  $\Rightarrow g'''(0)=1$ So I'm getting my listItems with a Camlquery, but i want to calculate the avg of the "price" rows  This is the code I've used so far:  function VisaLista() {     namn = document.getElementById("txtNamn");     var camlQuery = new SP.CamlQuery();     camlQuery.set_viewXml(     "&lt;Where&gt;" +     "&lt;And&gt;" +     "&lt;Eq&gt;&lt;FieldRef Name='Title'/&gt;&lt;Value Type='Text'&gt;" + namn + "&lt;/Value&gt;&lt;/Eq&gt;" +     "&lt;Or&gt;" +     "&lt;Eq&gt;&lt;FieldRef Name='Prioritet'/&gt;&lt;Value Type='Text'&gt;Hög&lt;/Value&gt;&lt;/Eq&gt;" +     "&lt;Eq&gt;&lt;FieldRef Name='Status'/&gt;&lt;Value Type='Text'&gt;Startad&lt;/Value&gt;&lt;/Eq&gt;" +     "&lt;/Or&gt;" +     "&lt;/And&gt;" +     "&lt;/Where&gt;");     listItems1 = list.getItems(camlQuery);     clientContext.load(listItems1);     clientContext.executeQueryAsync(OnSuccessVisa, OnFail); } function OnSuccessVisa() {     var listEnumerator = listItems1.getEnumerator();     var elmt = 0;     while (listEnumerator.moveNext()) {         var currentItem = listEnumerator.get_current();         elmt = (currentItem.get_item('_x0072_zb6'));          var sum = 0;         for (var i = 0; i &lt; elmt.length; i++) {             sum += parseInt(elmt[i], 10);         }          var avg = sum / elmt.length;          document.write("The sum of all the elements is: " + sum + " The average is: " + avg);     }     $("#Kategori1").text = "Medelvärdet för dessa ordrar: " + avg }   I am getting following error     "Cannot get the value length of null - at elmt, line 43 Let's say we have $2$ particles facing each other and each traveling (almost) at speed of light.    Let's say I'm sitting on #$1$ particle so in my point of view #$2$ particle's speed is (almost) $c+c=2c$, double light speed? Please say why I am incorrect :)    EDIT: About sitting me is just example, so in point of view of #1 particle, the second one moves at (almost) $c+c=2c$ speed? Why is Excel truncating my 16-digit numbers? If I type in a 16 digit number (format: number, no decimals) it changes the number on me. Example: 1234567812345678 changes the view to 1234567812345670.    If I type it in as a general format it changes the numbers above so it displays 1.23457E+15 but if you click on the cell, the display shows the last digit as a 0 instead of an 8 once again.   I opened the file on a different computer and same issue now with it.  I have changed the auto correction and auto formatting all to no avail.  Help! When should I use "a" vs "an"? How do I troubleshoot random rebooting? How to call the method correctly in Preference.OnPreferenceChangeListener() Is there some way to get explorer to generate thumbnails without actually having to navigate and scroll through every folder?  All I could get was a command prompt script that would load an explorer window for all subfolders, however only images that were visible would have thumbnails created. I have too many sections in my presentation such that the left-hand-side navigation bar is full and only shows the first sections in Fig. 2, initial situation in Fig. 1.  Pseudocode    clean the left-hand-hand side navigation bar when exceed the threshold and start a new one there when on sufficient page  this feature occurs with Beamer Berkeley appendix so it is possible also with the main document   Code which problem shown in Fig. 2   \documentclass{beamer} \usetheme{Berkeley}  \logo{\includegraphics{logo.png}} \usepackage{hyperref} % https://tex.stackexchange.com/a/346486/13173 \newenvironment{slide}[1] {\begin{frame}[environment=slide,allowframebreaks] \frametitle{\insertsection-#1} } {\end{frame}} % fragile only if code % allowframebreaks not by default   \begin{document}  \title{Sensory system. Primary sensory modalities. Cortical modalities. Kinds of sensory disturbances. Spinal cord disorders. Spinal cord transverse and partial lesion. Cauda equina damage.} \author{Leo}  \section{Cortical modalities} \begin{slide}{basics}      More refined aspects of sensation ... \end{slide}  \section{Cortical modalities} \begin{slide}{basics}      More refined aspects of sensation ... \end{slide}  \section{Cortical modalities 2} \begin{slide}{basics}      More refined aspects of sensation ... \end{slide}  \section{Cortical modalities 3} \begin{slide}{basics}      More refined aspects of sensation ... \end{slide}  \section{Cortical modalities 4} \begin{slide}{basics}      More refined aspects of sensation ... \end{slide}  \end{document}   Fig. 1 Situation at the first page,  Fig. 2 Situation at Section 6 wheere the navbar has not changed,  Fig. 3 Samcarter's answer output + one slide addition but without \part{} - fails on sufficient page count       Output: the left-hand-side navigation bar is not refreshed when the amount of sections exceed its capacity on suffcient enough page     Testing Samcarter's proposal  I include one slide before Samcarter's body so I get the wrong output in Fig. 3.  Solution: Eventually correct output by just adding \part{} in the place where the new navbar is wanted.   TeXLive: 2016 OS: Debian 8.7 limit: $u_n=\frac{1+2^2+3^3+...+n^n}{n^n}$. Let $u_n=\dfrac{1+2^2+3^3+...+n^n}{n^n}$. Prove that : $$\lim u_n=1$$ I tried to prove that $u_n&lt; something$ have limit  is 1 ; but I can't I have an iPhone 6. How can I use two Bluetooth audio devices and the 3.5mm audio jack together? Me and my friends want to listen to music together. Two of us have Bluetooth Headphones (Beats Solo2 Wireless, Beats Studio Wireless) and one has a wired headset. Is there any way to use all three of these together? I play on the DivineJourney modpack with a friend, but he wants to constantly spawn things in. Is there any way to allow him to be able to use the teleport command, but not be able to spawn in items?  I've already locked the NEI mode to Recipe.  I've looked around for a mod for plug-ins for Forge (as thats what the server is on) but I couldn't find anything thats up to date. I found Sponge, but thats for 1.8+, and I need 1.7.10. Can we query the info from "Data Management -> Storage Usage" through SOAP API? Please enable low-rep users to easily breakout up and down votes on their own questions I know once you get a certain amount of reputation, you can see the total up and down votes for questions. Well, my proposal is to always be able to see this on your own questions and answers. You can see it by going to your user page anyway, so why not make it possible to do by simply clicking on the number of votes (like you can when you have the rep)? I have a 12-hour layover in Istanbul. Will I be able to leave the airport to do some sightseeing in the city? I'm flying to Barcelona from Israel via Istanbul. The layover in Istanbul is 12 hours, and I'm thinking about leaving the airport and entering the country for a couple of hours. Would that be possible? Are there any Border/Airline restrictions?  I'm Traveling with Turkish airlines, and hold a passport which does not require a visa to enter Turkey.  I've done this in the past, but only inside the Schengen area, so this question is Turkey-specific.