Compare two Strings in python
python program to get two strings and check whether both are equal
Sample Input 1 :
MARK MAKE
Sample Output 1 :
Not Equal
Try your Solution
Strongly recommended to Solve it on your own, Don't directly go to the solution given below.
#write your code here
Program or Solution
s1=input("Enter first String:")
s2=input("Enter first String:")
if(len(s1)==len(s2)):
for i in range(0,len(s1)):
if(s1[i]!=s2[i]):
print("Not Equal")
break
else:
print("equal")
else:
print("Not Equal")
Program Explanation
if the length of two strings are not equal then strings are not equal else, visit each location of in strings and compare the characters in s1 and s2.
if all the characters are s1 and s2 are equal then the strings are equal else not equal.
Comments
Related Programs
- length of the string in python
- find a character in a String Python
- occurences of character in string python
- lowercase to uppercase in python
- uppercase to lowercase in python
- python count vowels in string
- find vowels in string python
- find substring in string pyhton
- occurences of substring in a String python
- Reverse the String in python
- string Palindronme in python
- Remove the spaces in String python
- Remove the Vowels in String Python
coming Soon
coming Soon