+ 1

Hey can you help me solve this problem : how to know if two words are annagramme . (A program that counts each currency )

Annagramme

30th Jan 2020, 6:13 AM
sara
9 odpowiedzi
+ 5
Even if there is already a solution here is mine. It treats upper and lower case equally. inp1 = list(input('first word').lower()) inp2 = list(input('second word').lower()) if sorted(inp1) == sorted(inp2): print('anagram') else: print('NOT anagram')
30th Jan 2020, 9:27 AM
Lothar
Lothar - avatar
+ 3
Thống Nguyễn Very cool... I didn't want to provide a complete solution because sara s brain needs food. Well yours is trained very well obviously👍
30th Jan 2020, 7:07 AM
Oma Falk
Oma Falk - avatar
+ 2
Hi, Two words are annagramme, If the occurrence of each character in both words is equal and both words have the same characters. Last one can be done through sets U could iterate one word and compare each currency of char to that of the 2nd one.
30th Jan 2020, 6:50 AM
Oma Falk
Oma Falk - avatar
+ 1
sara try this: def is_annagrmme(word1, word2): word1 = word1.lower() word2 = word2.lower() word1.split() word2.split() if len(word1) != len(word2): res = "False" else: res = "True" for char in word1: if char not in word2: res = "False" break print(res)
30th Jan 2020, 6:57 AM
Thống Nguyễn
Thống Nguyễn - avatar
+ 1
Lothar very intelligence solution!
30th Jan 2020, 12:23 PM
Thống Nguyễn
Thống Nguyễn - avatar
+ 1
Thank you. I just wanted to see different answers
30th Jan 2020, 8:10 PM
sara
0
Adding : A string is said to be an anagram if it contains same characters and same length but in different order. For example: If the input strings are 'listen' and 'silent'. The output should be True Hint: Sorting of 2 string will result same string.. Edit: If you are mean anadrom: Anadrom means which is Polindrom and anagram both. Polindrom is reversing will result same.. Ex: abcba https://www.sololearn.com/learn/5045/?ref=app
30th Jan 2020, 9:12 AM
Jayakrishna 🇮🇳
0
Oma Falk thank you! Yes, i think "show the way then let them walk" is the best. My ans for in case what she need is "fast food, not recipes".
30th Jan 2020, 12:31 PM
Thống Nguyễn
Thống Nguyễn - avatar
0
from itertools import permutations pal = lambda s: s==s[::-1] n=input() lis = {l for l in {"".join(u) for u in permutations(n)} if pal(l)} print(f"You entered {n} and it{' is an anadrome with the word(s) {}'.format(lis) if lis else ' is not an anadrome'} .")
30th Jan 2020, 8:08 PM
sara