Python: If Statement with String Ends With

4/9/2020 11:43:22 PM

Create an IF statement and check if a string ends with a certain value using the string endswith function or check if the string DOES NOT end with a certain value.

my_string = "stats.csv"

if my_string.endswith(".csv"):
	print("do something with this csv file")

#using not
if not my_string.endswith(".csv"):
	print("this isn't a csv file")