Problem 128269 · easy · Phase 01 Prerequisites & Setup

Is It an Image File?

strings · endswith · lower · tuples

A photo gallery should only accept image uploads. Given a filename name, return True if it ends with .png, .jpg, .jpeg or .gif, ignoring the case of the extension, and False otherwise.

Examples

Input:  name = "holiday.JPG"
Output: True

Input:  name = "notes.txt"
Output: False

Input:  name = "png"
Output: False

Constraints

  • 0 <= len(name) <= 200
  • name may contain letters, digits, dots, spaces, dashes and underscores

Goals

  • Check a suffix with `endswith`
  • Compare case-insensitively
  • Test against several options
Starting Python…