What is the syntax to see if a string ends with a value?

<string name>.endswith(<suffix>, <start>, <end>)
#suffix - string value to be searched with. Function yields true if searched portion of string ends with suffix
#start - search begins at this index, inclusive
#end - search ends at this index, exclusive
#example
str = 'HELLO WORLD'
print(str.endswith("WORLD"))
print(str.endswith("LO", 0,4))
print(str.endswith("LO", 0,5))

#output
True
False
True

 

Advertisements