Write a Python program to create and display all combinations of letters, selecting each letter from a different key in a dictionary.
class Solution:
def comb1(self,dict1):
list1=[]
for key in dict1.keys():
for key2 in dict1.keys():
if key!=key2:
for i in range(len(dict1[key])):
for j in range(len(dict1[key2])):
a1=dict1[key][i]+dict1[key2][j]
list1.append(a1)
list2=[]
for item in list1:
item=sorted(item)
item="".join(item)
list2.append(item)
list2=list(set(list2))
return(list2)
kk=Solution()
if __name__=="__main__":
print(kk.comb1({'1':['a','b'],'2':['c','d']}))
I wrote about the solutions to some problems I found from programming and data analytics. They may help you on your work. Thank you.
ezoic
Thursday, March 9, 2017
Subscribe to:
Post Comments (Atom)
looking for a man
I am a mid aged woman. I live in southern california. I was born in 1980. I do not have any kid. no compliacted dating. I am looking for ...
-
I tried to commit script to bitbucket using sourcetree. I first cloned from bitbucket using SSH, and I got an error, "authentication ...
-
https://github.com/boto/boto3/issues/134 import boto3 import botocore client = boto3.client('s3') result = client.list_obje...
-
There are some fun tools on Mac/PC which can help you on your studies, life and research. 1. Evernote: https://evernote.com/ To downl...
No comments:
Post a Comment