0
400views
write a python program to check if last three characters are same
1 Answer
0
13views

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 …

Create a free account to keep reading this post.

and 3 others joined a min ago.

Please log in to add an answer.