[Python] How can I check if two strings are anagrams of each other?

Discussão em 'Python' iniciado por Stack, Abril 27, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to write a program that accepts two strings from the user:

    s1 = input("Please enter a word:")
    s2 = input("Please enter another word:")


    How can I output True if the two are anagrams and False otherwise?


    If you found this question from a search engine and want to look for possibly multiple anagrams within a list: it is possible, but not optimal to compare each pair of elements. Please see Using Python, find anagrams for a list of words for more specific advice.

    Continue reading...

Compartilhe esta Página