Hi all. I'm kind of a python noobie, this is for my first usefull program, beyond just playing around with the language. Any help is appreciated. Here's the code that throws an error.
this throws me
if I switch the "files = " line for the commented one, everything works as it should
I've been banging my head on the keyboard for a couple hours now. It may be simple but I just don't see what's wrong.
Anyway... thanks for the help.
Code:
import re, os files = os.listdir(os.getcwd()) #files = ['blue13', 'red011', 'yellow1', 'green1000'] def getnum(filename): return float(re.findall(r'\d+',filename)[0]) def numsort(a,b): return cmp(getnum(a),getnum(b)) files.sort(numsort) print files
Code:
IndexError: list index out of range
I've been banging my head on the keyboard for a couple hours now. It may be simple but I just don't see what's wrong.
Anyway... thanks for the help.
Comment