from collections import Counter
substring_counts = Counter(substring)
text_counts = Counter(text)
if all(text_counts[letter] >= count for letter, count in list(substring_counts.
    items())):
    pass
Efficiently find whether a string contains a group of characters (like substring but ignoring order)?