Page Contents
Interview Content
- C Programming Coding Questions
- C Pattern Programming Questions
- C Programming Interview Questions
- Java Programming Coding Questions
- Java Pattern Programming Questions
- Java Programming Interview Questions
- Python Programming Coding Questions
- Python Pattern Programming Questions
- Python Programming Interview Questions
- SQL Interview Questions
Anagram Program in Python
Ans:
In this tutorial, you will learn the writing program in to check string is anagrams or not in Python.
Read This : What is Anagram? Write an anagram program in C.
How this Python program will behave?
This Python Program will take two String from user as an input. And after the comparison of two input string, program will return output.
If the string is anagram then Program will return “Given Strings are anagram”.
And if Strings are not anagram then it will return “Strings are not anagram”.
Anagrams program in Python
def anagramCheck(str1, str2):
if (sorted(str1) == sorted(str2)) :
return True
else :
return False
str1 = input("Please enter String 1 : ")
str2 = input("Please enter String 2 : ")
if anagramCheck(str1,str2):
print("Anagram")
else:
print("Not an anagram")
Output:
Also prepare these Python Programs:
- Write a program to reverse an integer in Python.
- Write a program in Python to check whether an integer is Armstrong number or not.
- Python Program to check a given number is Prime number or not.
- Write a program in Python to print the Fibonacci series using iterative method.
- Write a program in Python to print the Fibonacci series using recursive method.
Latest Uploads on Website
- AVL Tree with explanation
- Radix sort algorithm explanation with example
- Quick Sort Algorithm with explanation
- Bubble sorting algorithm with Bubble sort program in C
- Insertion sort algorithm and program in C
- Selection Sort Algorithm and Program in C
- Linear probing technique explanation with example
- Collision in Hashing and Collision resolution technique
- Hashing in data structure with its types
- Binary search tree operations with Program
- Binary search tree in data structure
- Binary search algorithm in data structure with explanation
- linear search in data structure with Algo and Program