forked from prathimacode-hub/Awesome_Python_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanagram_string.py
28 lines (16 loc) · 838 Bytes
/
anagram_string.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
# coding: utf-8
# In[2]:
# Script for strings are angram string or not.
string1 = input("enter string-1:") #user enter string 1
string2 = input("enter string-2:") # user enter strung 2
# check length of both string same or not.
if(len(string1) == len(string2)):
# if length same, sorting both string and check sorting string equal or not.
if(sorted(string1) == sorted(string2)):
print(string1 + " and " + string2 + " are anagram string.") # if equal then print both string are anagram stirng
else:
print(string1 + " and " + string2 + " are not anagram string.") # otherwise print both string are not anagram string
else:
print(string1 + " and " + string2 + " are not anagram string.") # length not same print both stirng are not anagram string
# In[ ]: