Python: Joining adjacent members of a list? I have a list that will always be of even length.  mylist = ['a', 'b', 'c', 'd', 'e', 'f']   What's the best way I can turn it into this:  mylist = ['ab', 'cd', 'ef']   I have this, and it works, but it seems hugely verbose:  myotherlist = [] for x in xrange(0, len(mylist), 2):     myotherlist.append(mylist[x] + mylist[x + 1])   Which returns this:  &gt;&gt;&gt; myotherlist ['ab', 'cd', 'ef']
How do you split a list into evenly sized chunks? I have a list of arbitrary length, and I need to split it up into equal size chunks and operate on it. There are some obvious ways to do this, like keeping a counter and two lists, and when the second list fills up, add it to the first list and empty the second list for the next round of data, but this is potentially extremely expensive.  I was wondering if anyone had a good solution to this for lists of any length, e.g. using generators.  I was looking for something useful in itertools but I couldn't find anything obviously useful. Might've missed it, though.  Related question:
YA dystopia novel of battle school with unusual military control scheme Does the sign of scores or of loadings in PCA or FA have a meaning? May I reverse the sign? 'A / One / At least one student entered the room.' Are these the same? (truth-conditionally) I just wonder if the two following sentences are truth-conditionally the same. Sentence 1 essentially means there existed a student who entered the room, and this situation includes two, three or more students entering the room. Hence, I believe these two sentences are truth-conditionally the same. Are they?        A student entered the room.   At least one student entered the room.      How about        One student entered the room      I gather this is different, as sentence 3 only means one student, not more and not fewer?  Any and all insights would be welcome. Is it possible to cross the Wagan border by car? I was planning a trip by car when I found something a bit weird in :if you try to cross from Lahore to India, it tells that you have to 6457 km detour.  Is it possible to cross this border driving? If not, is there another way to cross without having to make more than 6000 km? What to do about rep inflation? Overall reputation scores are headed nowhere but up.  Pretty soon there will be thousands of mods.  What to do?  Thoughts on possibilities:   Thousands of mods is fine.  Carry on. Adjust the threshold values for high-level SO privileges. Do a straight-up inflation adjustment.  You had x rep, then at the turn of the year we applied the Consumer Rep Index to all scores, now you have (x / inflation) rep. Implement a rep decay mechanism, so that inactivity sheds some of the overall rep that's built up. Why does casting an ArrayList 's generic to a superclass not work? I'm getting the following error message:     System.QueryException: Didn't understand relationship 'AccountContactRelation' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.   Select Email, Id, (Select ContactId, AccountId From AccountContactRelation) From Contact  In AccountContactRelation object there are two lookup fields for Account and for Contact.  Please advise how to avoid such error message? How does end-of-year interact with mutual fund prices (if it does)? Should I expect prices of mutual fund shares to go up in anticipation of dividends, down after dividends have paid out ... or just trust that the market has already reacted to that and the price is basically fair throughout the period?  (I've generally been paranoid and tended not to play with my funds around this time of year, but that may be pure superstition.)  Clarifications: USA, open-ended index funds are my immediate interest, but the answers would be most general if we could cover some of the other varieties (and, if folks are so inclined, locations). Let $a_1,a_2,a_3,\ldots$ be reals. Prove that if $\sum_{n=1}^{\infty} a_n^{2}$ converges, then so does $\sum_{n=1}^{\infty} \frac {a_n}{n}$.   For this I have shown the case for when $ a_n^{2} \le\frac {|a_n|}{n}$ $\Rightarrow$ $ |a_n|\le\frac {1}{n}$ $\Rightarrow$ $\frac {|a_n|}{n} \le \frac{1}{n^{2}}$ and we know that $\sum_{n=1}^{\infty} \frac {1}{n^{2}}$ converges and hence $\sum_{n=1}^{\infty}\frac {a_n}{n}$ converges by the comparison test. Now considering $ a_n^{2} \ge\frac {|a_n|}{n}$ $\Rightarrow$ $\frac {|a_n|}{n} \le a_n^{2}$ $\rightarrow$ combining the two cases for any n we have: $\frac {|a_n|}{n}\le\frac{1}{n^{2}}+a_n^{2}$ Hence using the comparion test again we know that $\sum_{n=1}^{\infty} a_n^{2}$ converges and $\sum_{n=1}^{\infty} \frac {1}{n^{2}}$ converges hence the sum converges so we can conclude that $\sum_{n=1}^{\infty} \frac {a_n}{n}$ is absoluetly convergent $\Rightarrow$ convergent.  Not to sure if this is correct, any help would be much appreciated, many thanks. What is the remainder of $\,3^{3^{3^{\:\!\phantom{}^{.^{.^.}}}}}\!\!\!$ divided by $46$?  The level of powers is $2020$.  First there is no parenthesis so it means 3 power of 3 which is also power 3 and so on 2020 times  Second I think that we can use Fermat's Little Theorem but I don't know how, and maybe there is a better way. Difference between HTMLCollection, NodeLists, and arrays of objects I used VIRTUALBOX to install Ubuntu 12.04 on my windows pc. I used apt-get to install Python 2.7 that shipped with 12.04. I followed the directives I saw on this site to install Numpy, Scipy, Matplot all failed. I download tar source file of these modules. How do I install them manually? Someone pls help, I'm getting frustrated. I am starting to learn using blender, and at some point I managed to do something to the 3D view camera.  Usually the camera orbits around an object, but now the rotation seems to happen (atleast very close to) around the "camera's origin". Neither the input setting in "User Preferences", the pivot point selection nor Ctrl-Alt-Shift-C (as suggested on some forum) do anything to the issue. Is it safe to delete from C:\Windows\Installer? I've been looking on an XP machine what is using all that diskspace, and it turns out C:\Windows\Installer is high up there on the list of directories that use the most diskspace.  It seems to contain a cache of msi and msp files.  Is it safe to delete those? To save diskspace, I've been deleting the "$KB...$" directories for ages without any problems. I want my Windows Updates in my system, why you would want to uninstall them is something that I have never understood. (Except when you're on an update revision board professionally or something of that order.) Why do I have to click twice to submit a question when Stack Exchange's automated question review has no advice to show? Find a plane that passes through a point and is perpendicular to 2 planes How do I find this limit: $\lim_{n\to\infty} \left[ n-{n\over e}\left(1+{1\over n}\right)^n \right]$? I'm working on a practice exam for my masters quals and I am having difficulties with the following limit. According to wolfram alpha, it's value is 1/2. Does anyone know how to find this limit?   $$\lim_{n\to\infty} \left[ n-{n\over e}\left(1+{1\over n}\right)^n \right].$$ Will using 'var' affect performance? Would it help if you jump inside a free falling elevator? Imagine you're trapped inside a free falling elevator. Would you decrease your impact impulse by jumping during the fall? When? Should I use "who" or "which" when referring to a specific animal species? I'd like to know what option to use, specifically when referring to a species by its scientific name.