Answer to Question #315171 in Python for sabiha

Question #315171

compare last three characters


write a program to check if the three last characters in the given two strings are the same


input


the first and second lines of inputs are strings


output


the output should be either true or false


explanation


given strings are apple ,pimple. in both strings, the last three characters ple are commom


so the output should be true.


sample input 1

apple

pimple


sample output 1

true


sample input 2

meals

deal


sample output 2

faslse


1
Expert's answer
2022-03-21T12:35:53-0400
def comp3char(s1, s2):
    return s1[-3:] == s2[-3:]


def main():
    s1 = input()
    s2 = input()

    if comp3char(s1, s2):
        print('true')
    else:
        print('false')

main()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS