Question: How do you test if a filename ( given as a string ) has an extension of . png , . jpg

How do you test if a filename (given as a string) has an extension of ".png",".jpg" or ".gif"?
if filename.endswith(".png" or ".jpg" or ".gif") :
if filename. endswith(".png") or filename. endswith(".jpg") or filename. endswith(".gif") :
if ".png" in filename or ".jpg" in filename or ".gif" in filename :
if filename. contains(".jpg",".gif", ".png") :
 How do you test if a filename (given as a string)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!