Writing better programs often comes down to attention to detail. One of those details is to python check if list is empty before proceeding with operations. This prevents bugs, saves system resources, and ensures your code performs consistently well. https://docs.vultr.com/python/examples/check-if-a-list-is-empty