I'm implementing a DFS algorithm and I want to create a list of dictionaries. But I found that if I use [dict()] * n, I got unexpected result.  I'm not sure what is the difference between "[dict()] * n" and a "for loop with .append(dict())".  Any hint is appreciated.  def DFS1(nums, level, target, dp):     if level == len(nums):         if target == 0:             return 1         else:             return 0      if target in dp[level]:         return dp[level][target]      cnt1 = DFS1(nums, level + 1, target + nums[level], dp)     cnt2 = DFS1(nums, level + 1, target - nums[level], dp)     dp[level][target] = cnt1 + cnt2     return cnt1 + cnt2   test code is:   nums = [1,1,1,1,1] n = len(nums) target = -3 #dp = [dict()] * n   #&lt;== This does not work as expected dp = [] for i in range(0, n):     dp.append(dict())  resCnt = DFS1(nums, 0, target, dp) print(resCnt)
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?
Can I switch the alt and ctrl keys on my keyboard? Finite Index of Subgroup of Subgroup Prove the following: If $H$ is a subgroup of finite index in a group $G$, and $K$ is a subgroup of $G$ containing $H$, then $K$ is of finite index in $G$ and $[G:H] = [G:K][K:H]$.  So this is basically a bijective proof? The number of cosets of $H$ in $G$ equals the number of cosets of $K$ in $G$ times the number of cosets of $H$ in $K$ by the multiplication principle?   Reference: Fraleigh p. 103  Question 10.35 in A First Course in Abstract Algebra Google Sheets has several import functions   IMPORTDATA IMPORTFEED IMPORTHTML IMPORTXML   Sometimes the above functions returns errors like #N/A Imported content is empty and would like to be sure that there isn't a problem with the resource content to be imported.  How do I know if these functions are able to get the content that I looking to import?  I know that there also exist IMPORTRANGE but that function only is able to import content from Google Sheets spreadsheets Simple past or past perfect with "by" and years What is the difference between      He became a star by 1990's.     He had become a star by 1990's.    Is the first sentence correct? If yes, then please tell me the difference between the two. Sources missing in /etc/apt/sources.list, how do I get them back? After I saw that post i wanted to solve the first one which is $a\mid b^2,b^2\mid a^3,a^3\mid b^4,b^4\mid a^5\cdots$ Prove that $a=b$  Now i started by proving that $a$ and $b$ have same prime divisors,proving that is trivial,after doing so I checked do those factors have to have the same power.I tried with $$a=p^2,b=p^3$$ I noticed it exactly goes for 3 terms,or that $a^3\mid b^4$ doing $$a=p^{n-1},b=p^n\\p^{n-1}\mid p^{2n}\\p^{2n}\mid p^{3n-3}\\p^{3n-3}\mid p^{4n}\\p^{4n}\mid p^{5n-5}\\\cdots\\p^{n(n-1)}\mid p^{n(n-1)}\\p^{n(n-1)}\mid p^{n(n+1)}\\p^{n(n+1)}\not\mid p^{(n-1)(n+1)}$$ Now yeah I guess that would be a proof,but wouldn't setting $n=n+1$ infinitely many times make every term dividable? My fish's native habitat is rice fields. My fish's native habitat are rice fields.   Which one is correct? I'm pretty sure it's the first, since 'is' modifies 'habitat,' but it still sounds weird... I have a JavaScript object. Is there a built-in or accepted best practice way to get the length of this object? const myObject = new Object(); myObject[&quot;firstname&quot;] = &quot;Gareth&quot;; myObject[&quot;lastname&quot;] = &quot;Simpson&quot;; myObject[&quot;age&quot;] = 21; Journal vs conference publications when looking for a job in in computer science I'm currently a post doc in theoretical computer science and I have a double digit number of conference publications, about half of which are at so called "tier 1" conferences (SODA,STOC,...). Unfortunately I only have 1 journal publication so far, mainly due to coauthors dragging their feet.   Will the lack of journal publications have a great impact when applying for a faculty job in cs-theory at some point, and is it advisable to try to up this number before applying? Or is this fully compensated by having sufficiently many conference papers? jQuery: Check if image exists Looking for a book series about a girl and her friends captured and sold as slaves I'm trying to find the name of a book series I read about 10 years ago. It might be a children/young-adult series since I was fairly young. There is also a small chance it was written by a french author, as I read it in french. The series is composed of at least three books, maybe more. Here is what I remember :   The main character is a poor girl/young woman, but there are several point of view characters At the beginning of the first book the plot is set in a city where rich people live in the city center and the further you go from the center the poorest people are. Moreover, the houses are painted according to the wealth of the owner. It was something like : the richer had red houses, the poorer blue houses, and the moderately wealthy purple (it was not those colors in particular but it was something like that) At the end of one of the book there is some kind of uprising and the people paint all the houses in multiple colorful shades (to symbolize the new found equality between the citizen) At some point the main character and other peoples of the city get captured (maybe after some kind of war the city was involved in), separated and sold to slavery One of them, an older boy, become a soldier and learn a special fighting technique that looks like dancing (and he grows to like it) Another of the captives, a young girl (the sister of the main character if I recall correctly) get marked with a fire-heated mark to show her condition of slave   That is all I remember, I have no clue about the time or geographic setting nor the story details.  I know it's not much to go by, any help would be greatly appreciated, as I would like to find these books and read them again. Listing multiple compound words Explicit vs implicit SQL joins Annoying lines ruining the image I was planning to do a 1920x1080 wallpaper from my favourite musician's cover. Everything was going good so far until I used correction brush which totally ruined my whole work. There are pixelated lines (how do I call these?!) everywhere! They're everywhere, it's very visible when zooming. Using Content-Aware Fill did nothing about it. I beg for help. Sorry if I did something wrong writing this post, i'm a beginner. Why doesn't matter pass through other matter if atoms are 99.999% empty space? The ghostly passage of one body through another is obviously out of the question if the continuum assumption were valid, but we know that at the micro, nano, pico levels (and beyond) this is not even remotely the case. My understanding is that the volume of the average atom actually occupied by matter is a vanishingly small fraction of the atom's volume as a whole. If this is the case, why can't matter simply pass through other matter? Are the atom's electrons so nearly omnipresent that they can simultaneously prevent collisions/intersections from all possible directions? Copy skype chat history to text files? I'd like to convert my Skype chat history to a collection of text files for archival purposes.  Ideally, I'd like to have a command (e.g. script or app) so that I could do this on a regular basis.  Any one have any idea on how to go about doing this? Reconfiguring TexStudio after upgrade to OS X El Capitan Texstudio doesn't work for me anymore after updating to Mac OS X 10.11 El Capitan. I have the latest version of TexStudio installed (2.10.2). As pointed out by , this is due to a change in the places OS X allows files to be saved. When I started TexStudio, I received a message "PDFLatex could not be launched". In the settings, I had to change the folder of the compiler from user/texbin/ to /Library/Tex/texbin, as shown in the screenshot below:    Can anybody tell me if I have to make further changes in order to make TexStudio fully working (bibliography and the like), and if yes, which?   I hope TexStudio are very soon going to release an update (there is an issue for this on their issue queue.  Thank you for your help. This is my first post here, so please apologize any imprecisions. Resize Move Partitions on Dual Boot System I use the following table:  \documentclass[a4paper,              12pt,                                        bibliography=totoc,              index=totoc,             abstracton,              headsepline,             ]{scrreprt}  \usepackage{booktabs}    \begin{document}   \begin{table}[H]\hspace*{-1cm} \centering \begin{tabular}{lcclll} \toprule  Company&amp; \multicolumn{2}{c}{exceedances (empirical)}&amp;exeedances (expected)&amp;no. of obs.\\ \cmidrule(r){2-3}\\ &amp;standard normal&amp;standardized Student's-t&amp;&amp;\\ \midrule Company1&amp;1&amp;5&amp;9&amp;13\\ Company2&amp;2&amp;6&amp;10&amp;14\\ Company3&amp;3&amp;11&amp;15\\ Company4&amp;4&amp;8&amp;12&amp;16\\ \bottomrule \multicolumn{4}{l}{\begin{footnotesize}an additional hint about a detail\end{footnotesize}} \end{tabular} \caption{Here is the caption.} \label{labelhere} \end{table}   \end{document}     Which gives    I have two problems:   The space after the \cmidrule(r){2-3} is too big, how can I change this? The table looks not that good, how can I improve it in general? Convergence of the series $\sum a_n$ implies the convergence of $\sum \frac{\sqrt a_n}{n}$, if $a_n>0$ I need help to solve following problem from Rudin's Mathematical analysis book:    Convergence of the series $\sum a_n$  implies the convergence of $\sum \dfrac{\sqrt {a_n}}{n}$, if $a_n&gt;0$  I tried to construct a suitable convergence sequence $b_n$ such that $\sum b_n$ converges and $a_n \leq b_n$ but, I am not able to find such sequence $b_n$ .  Thanks for the help and sugestions.