Skip to content

Instantly share code, notes, and snippets.

@tanviredu
Last active January 17, 2021 10:42
Show Gist options
  • Save tanviredu/6c47a3c89a7afa7e2447d9356e63b3b1 to your computer and use it in GitHub Desktop.
Save tanviredu/6c47a3c89a7afa7e2447d9356e63b3b1 to your computer and use it in GitHub Desktop.
data = ["eat","tea","tan","ate","nat","bat"]
print("INPUT : ",data)
def find_ord_sum(string):
res = []
for item in list(string):
res.append(ord(item))
return sum(res)
orw = []
for item in data:
orw.append(find_ord_sum(item))
key = list(set(orw))
r = []
for item in key:
b=[]
for i in range(len(orw)):
if item == orw[i]:
b.append(data[i])
r.append(b)
print("OUTPUT : ",r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment