endswith()
can take tuple as parameter.Using os.scandir() is faster than listdir().
import os with os.scandir('.') as it: count = 0 for pic in it: if pic.name.endswith(('.jpg', '.png')): count += 1 print(count)This will count all jpg and png images in a folder.
If need a separate count,split it up like heiner55 show.