Python IndexError on filename.split(‘.’): 4 Fixes (2026)
One of the most common Python beginner bugs: extracting a file extension with filename.split(‘.’)[1]. It works fine for “image.jpg” but raises IndexError on any filename without a dot (like “README” …