0
400views
write a python program to check if last three characters are same
1 Answer
written 2.1 years ago by | • modified 2.1 years ago |
Code
string=input("Enter the Sentence:- ")
#remove the special char from the string or else it would also be considered as the character
new_string = ''.join(char for char in string if char.isalnum())
#extract last three characters of the string
char=new_string[-3:]
print("Last three characters are:-",char)
#compare if all the characters are same …