Python ProgrammingPython Programming

How to check if string ends with one of the strings from a list?

str_list = ['aaa', 'bbb', 'ccc', 'ddd']  # list of items
str_test = 'testccc'  # string need to test
 
for str_item in str_list:
    if str_test.endswith(str_item):
        print("found")
        break   # loop ends when result found
    else:
        print("not found")
Sample output of above program.

not found
not found
found