My python code is just try to print all the permutation of a given list (num in my code). Here is my code  #!/usr/bin/python3              def permutation(list_num, checked_length, length):             if checked_length == length - 1:                 print(list_num)             else:                 for i in range(checked_length, length):                     list_num[i], list_num[checked_length] = list_num[checked_length], list_num[i]                     permutation(list_num, checked_length + 1, length)                     list_num[i], list_num[checked_length] = list_num[checked_length], list_num[i]           num = [1, 2, 3]         permutation(num, 0, len(num))   It gives out the result as i want to  [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 2, 1] [3, 1, 2]   but when i try to change just a little. I want the output of that code to store in Answer_list. I got this unexpected result:  [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]   Here is my code that got the result:          #!/usr/bin/python3     Answer_list = []     def permutation(list_num, checked_length, length):             if checked_length == length - 1:                 Answer_list.append(list_num) # change here             else:                 for i in range(checked_length, length):                     list_num[i], list_num[checked_length] = list_num[checked_length], list_num[i]                     permutation(list_num, checked_length + 1, length)                     list_num[i], list_num[checked_length] = list_num[checked_length], list_num[i]   num = [1, 2, 3] permutation(num, 0, len(num)) print(Answer_list)
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?
Is it logically correct to assert that the expectation of the momentum $$\langle \hat p \rangle=0$$ for any bound state because it is bound to some finite region? What is the physical interpretation of the fact that $$\langle \hat p \rangle=0$$ in an energy eigenstate $\psi_n(x,t)$  but $$\langle \hat p \rangle\neq0$$ in some superposition state $$\psi(x,t)=c_m\psi_m(x,t)+c_n\psi_n(x,t)~?$$ Here $\psi_n(x,t)$ the eigenstates of the Hamiltonian, for example, in the problem of particle in a box (say). How do I disable Aero Shake in Windows 7? I'm always accidentally minimizing most of my windows. This is really annoying. How do I disable Aero Shake? Continuous v. per-chapter/section numbering of figures, tables, and other document elements Some document elements (e.g., figures in the book class) are numbered per chapter (figure 1.1, 1.2, 2.1, ...). How can I achieve continuous numbering (figure 1, 2, 3, ...)?  And vice versa: Some document elements (e.g., figures in the article class) are numbered continuously. How can I achieve per-section numbering?  \documentclass{book}% for "vice versa" variant, replace `book` with `article`  \begin{document}  \chapter{foo}% for "vice versa" variant, replace `\chapter` with `\section`  \begin{figure} \centering \rule{1cm}{1cm}% placeholder for graphic \caption{A figure} \end{figure}  \end{document}   Bonus question: Is it possible to adjust the numbering of the sectioning headings themselves? Can I, e.g., switch from per-chapter to continuous numbering of sections in the book class? How do I extract a single chunk of bytes from within a file? Why shouldn't we allow NULLs? Can anyone please give an example of why the following definition of $\displaystyle{\lim_{x \to a} f(x) =L}$ is NOT correct?:  $\forall$ $\delta &gt;0$ $\exists$ $\epsilon&gt;0$ such that if $0&lt;|x-a|&lt;\delta$ then $|f(x)-L|&lt;\epsilon$  I've been trying to solve this for a while, and I think it would give me a greater understanding of why the limit definition is what it is, because this alternative definition seems quite logical and similar to the real one, yet it supposedly shouldn't work. Recover data from SD card How can I expand a partition into non adjacent free space using GParted? My dual-boot machine has partitions as follows:   sda1 50 GB NTFS sda2 15 GB unallocated sda3 20 GB ext3 sda4 20 GB ext4   I would like to allocate the unused space on sda2 to my Ubuntu partition on sda4, hopefully leaving the other two partitions untouched, leaving this configuration:    sda1 50 GB NTFS sda3 20 GB ext3 sda4 35 GB ext4   Is this possible? If so, how can it be done, preferably using GParted? How can I get dramatic shallow DOF with a kit lens? How do I append an object (such as a string or number) to an array in JavaScript? I have to prove that this is a metric: $$d(x,y):=\sum_{i=0}^\infty \frac{|x_i -y_i|}{2^i (1+|x_i-y_i|)}$$  The only thing that I can't prove is the triangle inequality, it's really hard. I know that $|x_i -y_i|\le |x_i -z_i|+|z_i -y_i|$, and I want to get: $$\frac{1}{2^i (1+|x_i-y_i|)} \le \frac{1}{2^i (1+|x_i-z_i|)}+\frac{1}{2^i (1+|z_i-y_i|)}$$ (I think...) The closest thing I've got is: $2^i (1+|x_i-y_i|)\le 2^i (1+|x_i-z_i|)+2^i (1+|z_i-y_i|)$ but... that's not quite what i want. I don't know how to get this... For $p$ prime, show that $\Phi_{p^n}(x) = 1 + x^{p^{n-1}} + x^{2p^{n-2}} + \dots +x^{(p-1)^{p^n-1}}$ Well I attempted to try this but I failed to solve it: So $$\Phi_{p^{n}}(x)= \frac{x^{p^{n}} - 1}{\Phi_{1}(x) \Phi_{p^{2}}(x) \dots \Phi_{p^{n-1}}(x)}$$  Now I'm just stuck here. I saw a result somewhere on the net that said $\Phi_{p^n}(x) = \Phi_p(x^{p^{n-1}})$. I would just use that, but I don't see why that result is true or know how to show that's true.  How do I approach this? If a run the watch command containing an alias, it will not expand the alias. I have tried both with single quote and double quotes, in fact given the following alias:  # alias ll alias ll='ls -l --color=tty'   The following command will fail  # watch ll sh: ll: command not found   Shouldn't command line expansion work in this case? Prove $|\arctan x - \arctan y|\leq |x-y|$ How can I accept the Microsoft EULA agreement for ttf-mscorefonts-installer? Accessing the iPhone's Call log with the iPhone SDK Merge files based on matching of first column I've been using the beta iCloud Photo Library for a week and a bunch of photos got duplicated and I'd like to wipe all the photos out and start over.  I have backups of all the photos and have turned off iPhoto Cloud Library on all iOS devices. When I log into the web app - it still shows dozens of albums and I can delete all the photos, then go to deleted items and then purge them, but the ghost albums are still there messing things up.  I've turned off the library entirely and you can see there is a 30 day waiting period.     If I click on albums, there are pages of them and no delete button anywhere. If I turn on the library on an iOS device, data starts flooding back as if I wanted to recover the photos.  I don't want to recover anything, I want a clean wipe and clean slate.  Currently, there are 7807 photos in the deleted album and no way to mass delete them. I have 31 albums that show up in iCloud and no way to delete them.  Is there some way to accelerate this or must people wait a month for a corrupt library to eventually be purged to start over?  (I have tickets open with AppleCare after  and it's escalated to engineering, but I was informed that it might be a week or two before it gets seen :-( Perhaps someone has a better idea to clear things out or noticed something I've missed.) I was trying to suggest a retag of  on Seasoned Advice, but the system won't let me; I get the familiar message     Edits must be at least 6 characters; is there something else to improve in this post?   In general, that's not true for retagging; if you don't change the question body at all, it should work. I suspect the logic checking the edit is thrown off guard because of the title warning:     The question you're asking appears subjective and is likely to be closed       I found , but I cannot find any evidence (in SEDE) for invisible characters being present in the question's source. Also, that's supposed to be . I had given an cipher text (of JSON string), an IV and a key. I tried decrypting using 's method:      decryptWithManagedIV(algorithmName, privateKey, IVAndCipherText)     //Sample code   Blob key = Blob.valueOf(decryptionKey);   Blob encryptedDatafor = EncodingUtil.base64Decode(bodystring);   Blob decryptedData = Crypto.decryptwithManagedIV('AES128', key, encryptedDatafor);    cipher = decryptedData.toString();   System.debug('Encrypted BodyString: ' +cipher);   and I was able to decrypt the cipher successfully. But when I use the provided IV with the following method:      decrypt(algorithmName, privateKey, initializationVector, cipherText)    //Sample code  Blob exampleIV = Blob.valueOf('HSDlUkhrmfEo7SgM'); //provided IV   Blob key = Blob.valueOf(decryptionKey);  Blob encryptedDatafor = EncodingUtil.base64Decode(bodystring);  Blob decryptedDataIV = Crypto.decrypt('AES128', key, exampleIV, encryptedDatafor);   cipher = EncodingUtil.base64Encode(decryptedDataIV );  System.debug('Encrypted BodyString: ' +cipher);   I get some string which looks like, it is still in the encrypted form (different from the encrypted string I have passed).   Update:  I have tried the below code-snippet based on the suggestion from @identigral, but I am still unable to decrypt the cipher using the IV:  Blob exampleIV = Blob.valueOf('HSDlUkhrmfEo7SgM'); //provided IV  Blob key = Blob.valueOf(decryptionKey); Blob encryptedDatafor = EncodingUtil.base64Decode(bodystring);  String encodedCipherTextAndIV = EncodingUtil.convertToHex(encryptedDatafor); String encodedCipherText = encodedCipherTextAndIV.substring(32); String finCipher = encodedCipherText.difference(encodedCipherTextAndIV); Blob ciphertext = EncodingUtil.convertFromHex(finCipher);   Blob decryptedDataIV = Crypto.decrypt('AES128', key, exampleIV, ciphertext);  decryptStg = EncodingUtil.base64Encode(decryptedDataIV ); System.debug('Decrypted BodyString: ' +decryptStg);