I have been given a list of  positive integer numbers upto 10^6 and total number of item in the given list will be 10** 4 at most. I want to store these values in a particular order as explained below. I want to iterate through the list and want to place the index value of item in the inner list corresponding to that item. Example Given List : [3,0,1,1] output : [[1],[2,3],[],[0]] #expected output basically output list should contains lists with index corresponding to item value in given list which should contain index value I have comeup with this solution. sequence = [[]] * 4 given = [3,0,1,1] index = 0 for num in given:     sequence[num].append(index)     index+=1 print(sequence)  but the output I am getting is [[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]] and cannot figure out why.
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?
The  claims that likelihood and probability are distinct concepts.     In non-technical parlance, "likelihood" is usually a synonym for "probability," but in statistical usage there is a clear distinction in perspective: the number that is the probability of some observed outcomes given a set of parameter values is regarded as the likelihood of the set of parameter values given the observed outcomes.    Can someone give a more down-to-earth description of what this means?  In addition, some examples of how "probability" and "likelihood" disagree would be nice. How to generate a random number between 1 and 10 with a six-sided die? How to split 7.1 soundcard outputs to 4 stereo outs with ALSA How can I install the Google Apps Package (Play Store, ...) on my Android device? I have recently installed a custom ROM and cannot find the Play Store. It seems like all apps that belong to Google are missing.  How can I install the Google Apps Package (Play Store, ...) on my Android device? I am trying to recreate a penne pasta. I am creating a cylinder removing the two end faces and then I solidify the mesh.  However I do not know how to extrude (or cut away) the two ends to make them pointy like in the picture of the penne below. I have tried to use bisect and mirror, but without successful results.  Any idea? I want to sort in-text citations by year, but bibliography by name. It sound exactly like .  However, suggested solution (using \usepackage[sorting=ynt]{biblatex} and \printbibliography[sorting=nty]) does not work for me (see MWEB below). Indeed, the list of references remains year-sorted instead of name sorted.  Question: How to force sorting=nty in \printbibliography?      \documentclass{article}     \usepackage[%         backend=biber,%         style=authoryear-comp,%         natbib=true,%         sorting=ynt%     ]{biblatex}     \addbibresource{\jobname.bib}     \usepackage{filecontents}  \begin{filecontents}{\jobname.bib}     @book{key2000,       author = {Author, A.},       year = {2000},       title = {Alphabetical fist \&amp; Year last},       publisher = {Publisher},     }     @book{key1900,         author = {Boathor, B.},         year = {1900},         title = {Alphabetical last \&amp; Year first},         publisher = {Publisher}, } \end{filecontents}  \begin{document}     Citation should be year-sorted, even if \verb+\citep+ is random \citep{key2000, key1900}.% citation NOT year-sorted      \printbibliography[sorting=nyt] \end{document}   P.S.: At the opposite, using  \begingroup     \newrefcontext[sorting=nyt]     \printbibliography \endgroup    overrides the \usepackage[sorting=ynt]{biblatex} option (i.e. LoR is name-sorted, but in-line citations as well). The number of (non-equal) forests on the vertex set V = {1, 2, ...,n} that contains exactly 2 connected components is given by The number of (non-equal) forests on the vertex set V = {1, 2, ...,n} that contains exactly 2 connected components is given by $\sum_{k=1}^{n-1} {n-1 \choose k-1} k^{k-2} (n-k)^{n-k-2}$.  I am unsure how to approach this question. Could someone guide me through the proof? If G is a spanning tree and it is disconnected then I know it is a spanning forest. Also, I know by Cayley's thm that there are $n^{n-2}$ nonequal tree on a vertex set V = {1, 2, ...,n} which is where i'm assuming the $k^{k-2}$ comes from but I do not understand where the rest of it is coming from. This is purely a curiosity, but I'm fascinated by mid-word pluralization, even if the word in question is a compound word.  For example, passersby or standersby.  No others have occurred to me. Can you provide other examples, or a link to a resource that enumerates them?  I'm particularly interested in compounds that do not include spaces or hyphens. Set horizontal width on custom listings environment I want to create a custom listings environment and want to set its width as something like 90% of textwidth, centred.  Per an  for algorithms, the first thing I tried was to embed the listing in a minipage environment. However, . I found a way to still make standard environment work, but it requires to use the escape command every time before ending the environment.  The second thing I tried was this latter command, but as far as I can see, it doesn't offer a feature to set the width of the listing or centre it.  \documentclass{article} \usepackage{listings} \usepackage{lipsum}   \lstnewenvironment{queryl} %% APPROACH 1  {\lstset{frame=shadowbox,escapechar=`}}  {}  \newenvironment{query} %% APPROACH 2  {\begin{minipage}{4cm}\centering\begin{queryl}}  {\end{queryl}\end{minipage}}   \begin{document} %% APPROACH 1 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. \begin{queryl} begin { do nothing } end ; \end{queryl} Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.  %% APPROACH 2 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.  \begin{query} begin { do nothing } end ;`%&lt;- needs escape-to-LaTeX character to work \end{query}  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. \end{document}     One can note that for the first environment, the frame extends beyond the width of the text. Also, puzzlingly the minipage environment doesn't seem to want to centre and swallows space (though I guess I could perhaps at least get that to work with tinkering).  In any case, does anyone have any ideas on how to set a width for a custom listings environment and centre it without requiring use of the escape character each time to end the environment? After a lot of messing around today I curiously observed that $a^2+b^2$ is only divisible by 3 when both $a$ and $b$ contain factors of 3.  I am trying to prove it without using modular arithmetic (because that would be way too easy), but finding it very difficult to do so.  Is there an easy way to prove this without using modular arithmetic?  I am also interested in a more general statement.  Namely, I want to find the values of $Z$ for which $Z \mid \left( a^2+b^2 \right)$ necessarily implies that $Z \mid \gcd \left( a,b\right)$.  We know that $Z$ cannot be 5, because $3^2+4^2=5^2$.  More generally, if $Z$ is the largest element of a pythagorean triple then the above implication does not hold. Should questions where a problem arose from a typo be closed? Should questions where a problem arose from a typo be closed?  Here is a recent example:    The problem was a misspelled _gaq (written as _gat).   Should these be closed? Surely they're of no use to anyone once the OP recognizes the mistake. If so, what justification should be given? Not a real question? Too localized?     Just to be clear, the question linked above actually was not broken due to a typo. This was my mistake, and raises some other interesting questions. See the discussion below.  If anyone feels like editing this question with examples of actual typo questions, go for it. Randomly place and scale objects? Food in the Star Wars Universe? Prove that for every prime $p$, there exists a solution to $(x^2-2)(x^2-6)(x^2-3) \equiv 0 \mod(p)$ So far: I know that$\mod(p)$ is a field thus one of the factors in the expression has to equal $0$ $\mod(p)$ for some $x$. However I just don't know where to continue from this point? How do I approach a congruency like this? Are there any general tips for problems like these?  Thanks for all the help. How to increase swap size? Remove files with 0 length inside bash I want to create a bash script inside Linux terminal to go into a file and then delete it if it's empty:  #!/bin/bash echo " Enter name of a directory" read Dir for Directory in $( ls $HOME ) do    test -d $HOME/$dir   if [ $# -eq 0 ]   then      for filename in $( ls $HOME/$Dir )     do        test -d $HOME/$dir/$filename       if [ ! -s "$filename"  ]       then         rm $HOME/$dir/$filename       else          echo " not empty"       fi      done    else      echo " $Dir is not a directory"    fi  done   This is the code I am using but it does not work. It recognizes the file created but doesn't delete it even when empty. It Salah displays there is no such file or directory How do I grep for multiple patterns on multiple lines? There's no need to  the  that have led to a lack of trust between  of  and . Suffice it to say that astoundingly they continue to assert that  and, instead of apologizing and reinstating Monica have demanded that she go through a process with no transparency, due process, or involvement from the community.   Has the time has come for Stack Exchange, Inc to spin off the community and all the data needed to keep the sites running to a separate non-profit, who would then in turn license the software from the company?  What's in it for the community?   The community can practice self determination for issues from as basic as the number of moderators they have to as fundamental as the policies they enforce. If the company development continues to be unresponsive to the community's needs, the community would be able to develop its own open source software that would meet its needs. They can find their own funding model instead of having ads imposed on them.   What's in it for the company?   Community actions will no longer reflect on the company. Interaction with the community as a customer may come more naturally to current leadership than the present paradigm. They don't have to worry about paying for the community's operating expenses. They can focus on doing one thing well. I am from a physics background and my mathematics is not very good, so pardon my insolence with the question.  Editing based on the comments : We know that $\pi$ in decimal (i.e. base 10) is transcendental. Is it possible to have a radix base in which $\pi$ can be rational in that base ?  PS : My question is in general for any transcendental number. I'm using biblatex and I have it set up like this:  In my bib file I have 3 sorts of entrys, online, booklet, and book.   And in my thesis I want them printed separate like this:  \printbibliography[heading=subbibliography,title={Books},type=book, nottype=url, nottype=booklet, nottype=online] \printbibliography[heading=subbibliography,title={Websites},type=online, nottype=book, nottype=booklet, nottype=url] \printbibliography[heading=subbibliography,title={Misc},type=booklet]   For some reason this won't work, it still puts the websites where the books should be. And vice versa. The booklet thing does work though, it only shows my booklet entries there.  I recently started using biblatex so this might be a stupid question.