Okay, so I know what an IndexError is and all, but that doesn't help me understand why on earth I'm getting this one. I'm writing a program that's supposed skim through directories, dump all files into one list and all directories into another. That's as far as I've gotten now because this is where the nasty error shows up at the very beginning. So without further ado, here's my script:
[code=python]
import os
tralla='/windows'
tintin='/LOLOL'
list1=[]
list2=[]
for item in os.listdir(tral la):
if os.path.splitex t(item)[1][0]=='.':
list1.append(it em)
else:
list2.append(it em)
for item in os.listdir(tint in):
if os.path.splitex t(item)[1][0]=='.':
list1.append(it em)
else:
list2.append(it em)
for item in list2:
print item
[/code]
So can anyone tell me why on earth I get this:
"Traceback (most recent call last):
File "untitled.p y", line 8, in <module>
if os.path.splitex t(item)[1][0]=='.':
IndexError: string index out of range"
?
At least this time it's with tab-indents, some people didn't like it when I used spaces last time... :)
Any help I can get is appreciated.
[code=python]
import os
tralla='/windows'
tintin='/LOLOL'
list1=[]
list2=[]
for item in os.listdir(tral la):
if os.path.splitex t(item)[1][0]=='.':
list1.append(it em)
else:
list2.append(it em)
for item in os.listdir(tint in):
if os.path.splitex t(item)[1][0]=='.':
list1.append(it em)
else:
list2.append(it em)
for item in list2:
print item
[/code]
So can anyone tell me why on earth I get this:
"Traceback (most recent call last):
File "untitled.p y", line 8, in <module>
if os.path.splitex t(item)[1][0]=='.':
IndexError: string index out of range"
?
At least this time it's with tab-indents, some people didn't like it when I used spaces last time... :)
Any help I can get is appreciated.
Comment