+ 1
Hey can you help me solve this problem : how to know if two words are annagramme . (A program that counts each currency )
Annagramme
9 ответов
+ 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')
+ 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👍
+ 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.
+ 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)
+ 1
Lothar very intelligence solution!
+ 1
Thank you. I just wanted to see different answers
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
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".
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'} .")