What I want to do: I have a list now and want to add it to the bottom of the existing text file. However, when the new line is added, the commas doesn't appear  What I have done so far: Current txt file:  food,bought oranges,yes strawberry,no   my code  choice=input("What fruit?") item=[] item.append(choice) item.append("No")  with open('groceries.txt', 'a+') as file:     file.writelines(item)   result of my code  food,bought oranges,yes strawberry,no applesno   I want it to appear like this:  food,bought oranges,yes strawberry,no apples,no   I tried to add the comma eg. item.append(choice+",") but it will change the result when i use index later on Any way to solve this?
What would be your preferred way to concatenate strings from a sequence such that between every two consecutive pairs a comma is added. That is, how do you map, for instance, ['a', 'b', 'c'] to 'a,b,c'? (The cases ['s'] and [] should be mapped to 's' and '', respectively.)  I usually end up using something like ''.join(map(lambda x: x+',',l))[:-1], but also feeling somewhat unsatisfied.
I am wondering what sudo apt-get update does?  What does it update? Multiple TikZ keys with foreach MySQL single table static and dynamic pivot I have a table that looks like this:  +----------------------------------------+ |Name                | kode      | jum   | +----------------------------------------+ | aman               |kode1      | 2     | | aman               |kode2      | 1     | | jhon               |kode1      | 4     | | amir               |kode2      | 4     | +--------------------+-----------+-------+   How can I make a view like this with MySQL?                      kode1    kode2     count aman                  2         1        3   jhon                  0         4        4 amir                  0         4        4 How to make a half cylinder? I am having a tough time building a half cylinder and have not found any tutorial showing me how to do that. Let's say that there is a question asked in a bad manner, in a way that the question is missing. For example the user shows the code and doesn't explain very well which is the problem.    Usually someone starts digging in the OP mind posting comments and asking him for details. It may happen that the question gets edited and the OP edits it to a valid question.    Do you usually give the OP time to edit the question or you immediately vote to close it? A commutative ring is a field iff the only ideals are $(0)$ and $(1)$ Why is Sauron called "the Necromancer"? During the time period of The Hobbit, a character is mentioned called the Necromancer.  Radagast even (in the movie) specifically states that the Necromancer can "summon the spirits of the dead."  (It's been a while since I read the book so I don't know if this exact phrasing is used there, but given the name it seems reasonable.) This character is later revealed to be Sauron.  Since when can Sauron summon the spirits of the dead?  He can extend life ad infinitum, like Gollum's, for example, and he can twist people into half-alive monsters, like the Ringwraiths, and he himself seems impossible to kill so long as the One Ring remains, but I can't recall ever actually seeing him "summon" something that was once fully dead.  In fact, the only character I remember doing that was actually Aragorn, though he merely commanded them and didn't raise them himself.  Is this just an unfounded rumor about the power in Dol Guldur, some hushed-whisper nightmare that isn't actually an accurate description, or is there a reason he is called the Necromancer?  It seems like if Sauron could actually resurrect the dead, what little chance Middle Earth had of defeating his hordes would be long, long gone... When will my phone get the Android 2.3 update (Gingerbread)? Force MacBook to drain the battery while connected to charger I leave my MacBook Pro on my desk nearly all the time, connected to the charger with the lid closed, connected to an external display.  I've heard this is bad for the battery health, and everyone in my office have to replace swollen batteries every couple of years. I want to regularly discharge the battery, per , but I don't want to physically unplug it because that temporarily turns off the external monitor, and then I have to reconnect the monitor.  So I am looking for a software method of disabling the power input, to force the laptop to discharge its battery to 20% and then re-enable the power input. Suppose that $f(x)$ is continuous on $(0, \infty)$ such that for all $x > 0$,$f(x^2) = f(x)$. Prove that $f$ is a constant function. Suppose that $f(x)$ is continuous on $(0, +\infty)$ such that for all $x &gt; 0$,$f(x^2) = f(x)$. Prove that $f$ is a constant function. My attempt is to show that for any point $a \neq b$ , we have $f(a)=f(b)$. But I have no idea on how to get this. Anyone can help? Some Git commands take commit ranges and one valid syntax is to separate two commit names with two dots .., and another syntax uses three dots ....  What are the differences between the two? random access file in java I have the following fields:   Inventory control (16 byte record)   Product ID code (int – 4 bytes) Quantity in stock (int – 4 bytes) Price (double – 8 bytes)    How do I create a fixed length random access file using the above lengths? I tried some examples online, but I either get an EOF exception or random address values when I try to access them.  I tried some more examples and couldn't understand the concept very well. I'm trying a project with it and will try to explore more on it.  Here is some example data. There might be holes in the data where No. in stock could be 23 == 023.            Quantity ID. No.   In Stock   Price  -------   --------   ------  1001       476      $28.35  1002       240      $32.56  1003       517      $51.27  1004       284      $23.75  1005       165      $32.25   Thanks for the help. I have shown that a smooth solution of the problem $u_t+uu_x=0$ with $u(x,0)=\cos{(\pi x)}$ must satisfy the equation $u=\cos{[\pi (x-ut)]}$. Now I want to show that $u$ ceases to exist (as a single-valued continuous function) when $t=\frac{1}{\pi}$.  When $t=\frac{1}{\pi}$, then we get that $u=\cos{(\pi x-u)}$.  With single-valued function is it meant that the function is 1-1 ?  If so, then we have that $\cos{(2 \pi-u)}=\cos{(4 \pi -u)}$, i.e. for two different values of $x$, we get the same $u$, and so for $t=\frac{1}{\pi}$, $u$ is not 1-1.  But if this is meant, how are we sure that for $t \neq \frac{1}{\pi}$ the function is single-valued? I have a very large dataset and about 5% random values are missing. These variables are correlated with each other. The following example R dataset is just a toy example with dummy correlated data.  set.seed(123)  # matrix of X variable  xmat &lt;- matrix(sample(-1:1, 2000000, replace = TRUE), ncol = 10000) colnames(xmat) &lt;- paste ("M", 1:10000, sep ="") rownames(xmat) &lt;- paste("sample", 1:200, sep = "") #M variables are correlated   N &lt;- 2000000*0.05 # 5% random missing values  inds &lt;- round ( runif(N, 1, length(xmat)) ) xmat[inds] &lt;- NA  &gt; xmat[1:10,1:10]          M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 sample1  -1 -1  1 NA  0 -1  1 -1  0  -1 sample2   1  1 -1  1  0  0  1 -1 -1   1 sample3   0  0  1 -1 -1 -1  0 -1 -1  -1 sample4   1  0  0 -1 -1  1  1  0  1   1 sample5  NA  0  0 -1 -1  1  0 NA  1  NA sample6  -1  1  0  1  1  0  1  1 -1  -1 sample7  NA  0  1 -1  0  1 -1  0  1  NA sample8   1 -1 -1  1  0 -1 -1  1 -1   0 sample9   0 -1  0 -1  1 -1  1 NA  0   1 sample10  0 -1  1  0  1  0  0  1 NA   0   Is there a (best) way to impute missing values in this situation? Is the Random Forest algorithm helpful? Any working solution in R would be much appreciated.  Edits:  (1) Missing values are randomly distributed among the variables and samples.As number of variables is very large (here in the example - 10000), while the number of samples is small here in the above dummy example it is about 200. So when we look at any sample over all the variables (10000), there is high chances that there will be missing value at some variable - due to large number of variables. So just deleting the sample is not option.   (2) The variable can be treated both as quantitative or qualitative (binary) in the process of imputing. The only judgement is how well we can predict it (accuracy). So predictions like 0.98 instead of 1 might be acceptable rather 0 vs 1 or -1 vs 1. I might need to tradeoff between computing time and accuracy.   (3)  The issue I have thinking how overfitting can affect the results as the number of variables are large compared to number of samples.   (4) As the total quantity of missing values is about 5% and is random (not concentrated in any variables or samples as precaution was taken to remove the variables or samples that have very high missing values)   (5) Making data complete for analysis is first objective and accuracy is secondary. So not too sensitive to accuracy. If a friend wants to transfer $7000 to me, what is the best way to do it, especially if we don't share the same banks? We could do wire transfer, but that comes with its own fees. Could we also do direct deposit? Paypal doesn't allow such large lump sum transfers.  This would be US-to-US transfer. Jquery Validation for dynamically added rows that has multiple element with same name New questions, Show Recommended, Sort Newest not working “community wiki” checkbox in new question shows a dialog twice when self-answering Click Answer your own question Check community wiki A dialog box     Are you sure you want to make this post Community Wiki?   will appear, Click OK or Cancel; The same dialog will appear again.   Google Chrome 44.0.2403.107 / Windows8.1 / site rev 2015.7.25.3609 I know that the finite sum of Bernoulli i.i.d. random variables is a binomial distribution, but what is the distribution of $$\lim_{n \to \infty}\sum_{k=1}^{n} \frac{x_k}{2^k}$$ where $x_k$ is a Bernoulli random variable with parameter $\frac12$? "NG NS" on ticket after airport security