Advertisement
Lonely_Wanderer

строки анаграммы

May 25th, 2023
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. def magic(s1,s2):
  2.     m1 = {i:s1.count(i) for i in set(s1)}
  3.     m2 = {i:s2.count(i) for i in set(s2)}
  4.     for i in m2.keys():
  5.         if not i in m1.keys() and m2[i]!=m1[i]:
  6.             return False
  7.     return True
  8.  
  9. print(magic("мошкара","ромашка"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement