Compare Last Three Characters
Write a program to check if the last three characters in the two given strings are the same.
The first and second lines of inputs are strings.
The output should be either True or False.
Given strings are
apple, pimple. In both the strings, the last three characters ple are common. So the output should be
True.
Sample Input 1
apple
pimple
Sample Output 1
True
Sample Input 2
meals
deal
Sample Output 2
False
first = input("Enter first word: ")
second = input("Enter second word: ")
if first[len(first) - 1] == second[len(second) - 1] and first[len(first) - 2] == second[len(second) - 2] and first[len(first) - 3] == second[len(second) - 3]:
print("True")
else:
print("False")
Comments
Leave a comment