- 4

Python

Python sorted() to check if two strings are anagram Or not - "dog" and "god"

17th Jul 2021, 4:51 AM
Chintala Madhuri
Chintala Madhuri - avatar
2 Respostas
0
You could cast one string as a list, invert it, cast back to string and comparenit with the other string some_string = 'god' some_other_str = 'dog' inverted_list = list(some_string)[::-1] inverted_string = "". join(inverted_list) if some_other_str == inverted_str: print("anagram")
17th Jul 2021, 8:21 AM
Zen Coding
Zen Coding - avatar