Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simplyfy
#6
Could not resist the temptation Idea
In [2]: word_set = set('abcde')

In [3]: two_letter = [left + right for right in word_set for left in word_set - set([right])]

In [4]:  print(two_letter)
['ec', 'dc', 'ac', 'bc', 'ce', 'de', 'ae', 'be', 'cd', 'ed', 'ad', 'bd', 'ca', 'ea', 'da', 'ba', 'cb', 'eb', 'db', 'ab']
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Messages In This Thread
Simplyfy - by podge - Apr-30-2017, 04:38 PM
RE: Simplyfy - by buran - Apr-30-2017, 04:50 PM
RE: Simplyfy - by nilamo - Apr-30-2017, 05:11 PM
RE: Simplyfy - by podge - Apr-30-2017, 06:00 PM
RE: Simplyfy - by nilamo - Apr-30-2017, 07:08 PM
RE: Simplyfy - by volcano63 - Apr-30-2017, 07:49 PM
RE: Simplyfy - by nilamo - Apr-30-2017, 08:21 PM
RE: Simplyfy - by volcano63 - Apr-30-2017, 08:30 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020