def number_of_cases(list_data):     result = []      for i in list_data:         for j in list_data:             result.append(str(i) + str(j))      return result  print(number_of_cases(['a', 'b', '1', '2']))   Whatever I input as the list_data argument, I want to get a deduplicated list of number of cases. But when the argument is ['a', 'a'], I get ['aa', 'aa', 'aa', 'aa'], not ['aa']. How do I remove duplicated elements in a list while preserving their order using list_data.count() (because this is homework)?
Is there a built-in that removes duplicates from list in Python, whilst preserving order? I know that I can use a set to remove duplicates, but that destroys the original order. I also know that I can roll my own like this:  def uniq(input):   output = []   for x in input:     if x not in output:       output.append(x)   return output   (Thanks to  for that .)  But I'd like to avail myself of a built-in or a more Pythonic idiom if possible.  Related question:
Unexpected output of xargs The statement below should print afc abc but it prints abc abc instead. I tried many times but every time same result Don't know why this happens could anyone explain and help me?  echo abc|xargs -i{} echo $(echo {}|sed 's/b/f/g') {} Index notation Lorentz transfromation matrix How do I make Panel always transparent like the Dock in GNOME 3? I'm using Ubuntu 17.10. I want the Panel to be always transparent instead of dynamic transparency. Natural Sort in MySQL How does substituting Butter for Margarine/Shortening affect the Recipe Custom related list button is not working in partner portal I have created custom button called "New Employee" on employee object and it is related with both account and contact objects via lookup relation. If i click on "New Employee" button on employee related list under Account detail page, working fine in both salesforce classic and lightning experience but not in partner portal.  /a03/e?CF00N342300009cAB8={!Account.Name}&amp;CF00N342300009cAB8_lkid={!Account.Id}&amp;CF00N90000009cUVB={!Contact.Name}&amp;CF00N90000009cUVB_lkid={!Contact.Id}&amp;retURL={!Account.Id}   Any help on this. How can I prevent someone from resetting my password with a Live CD? Recently one of my friends came over to my place, within 15 minutes he hacked my account using a Live CD and reset the password in front of me. I was baffled to see such a thing. Please guide me to prevent such a future attempt using a Live CD. Solving a Diophantine equation with a large solution Why can't we downvote our own posts? Once in a blue moon, I've wanted the ability to downvote my own answer to some question.  ()  Obviously upvoting one's own posts is out of the question.  But down is different.  Voting my own answer down can help me improve the site by pushing my answer lower in the ranking than another answer with a better or more situation-appropriate alternative.  It's not something I'd do often, but I would use this feature if it were available.  If implemented, I'd expect this feature to operate just like downvotes on other user's posts.  That is:   I get a few seconds to undo the downvote;  I get to remove the downvote after an edit to the post;  I lose a point for placing the downvote (CW excepted); I lose two points for receiving the downvote (CW excepted).   If you're noticing that I'd lose 3 points for downvoting my own non-CW post, congratulations! You can add!  I can think of a couple of potential downsides to this change.  The first one may be a dealbreaker; the second is probably not that big a deal.   Strategic downvoting of oneself: since you can undo the vote after an edit, and you can always edit your own posts, someone could downvote themselves soon after posting (especially on a FGITW answer) to garner extra sympathy upvotes. Badge collecting: the Peer Pressure badge just got easier, because if you have a -2 score on an answer, just downvote and delete for an instant badge. Proper submodules of Noetherian modules are intersections of indecomposable modules If $M$ is Noetherian, any submodule $N \neq M$ can be written as a finite intersection of intersection-indecomposable ones.   I just don't know how to begin with the proof of this proposition.   Very kind of you for reading or answering. Intuitive explanation for dividing by $n-1$ when calculating standard deviation? I was asked today in class why you divide the sum of square error by $n-1$ instead of with $n$, when calculating the standard deviation.  I said I am not going to answer it in class (since I didn't wanna go into unbiased estimators), but later I wondered - is there an intuitive explanation for this?! How can I send mail from an iPhone application Schur's theorem and numbers Can you give a proof for bounds of  $S(r)$? Please suggest me articles to have better idea of Schur's theorem (Ramsey theory). Is there a way to arrange windows within the same application in the taskbar of Windows 7?  Right now we can freely adjust each application's position in the taskbar, but within the app itself the windows can't be reordered, for example multiple windows of firefox or chrome. Logging individual application network usage in Windows 7 There are many answers here detailing programs that will monitor and log internet usage for a pc, but I need that usage to be logged and broken down, detailing which applications consumed that data.  I've noted there are several that give a real-time feed of each application's data usage (NetLimiter, Win7 Resource Monitor), but I can't find one that will log such data.  Anyone know of one?  Need to track down which program is using up a friend's bandwidth! Lewis Carroll's Pillow Problem via Bayes' Theorem In Pillow Problems and a Tangled Tale Lewis Carroll presents the following problem:     A bag contains a counter, known to be either white or black. A white counter is put in, the bag is shaken, and a counter is drawn out, which proves to be white. What is now the chance of drawing a white counter?   One can easily reason that in the end, the bag must be in one of three states:   Black remains, new white taken New white remains, original white taken Original white remains, new white taken   In two of those states, a white counter remains to be drawn. Therefore, the chance is 2/3.  How can one arrive to this answer using Bayes' theorem? How do I backup ssh keys? I am planning to do a fresh install of ubuntu 11.10 in my system. Before that i have setuped key based ssh authentication in this machine. Is it possible to take backup of those ssh keys, so that i  can use that in my new installation. Or else i must setup keybased ssh authentication again? If i can take backup, what are the files i need to copy? Can someone explain it in detail pls. Thanks in advance. In the King James version of the Bible there is a verse like this:     The Lord is my strength, and my fortress, and my song. And He is become my salvation.   Is it still feasible to use "is become" instead of "has become" and what is the semantic difference? How to get world-space matrix of any pose bone? Is there a command for getting world-space matrix of pose bones, same as obj.matrix_world for objects? I found pose_bone.matrix, but it gives weird result for me. How should I detect unnecessary #include files in a large C++ project?