+1  A: 

Python is white-space sensitive, so you need to make sure that everything you want inside the function is indented.

Stackoverflow has its own indentation requirements for code, which makes it hard to be sure what indentation your code originally had.

import os, glob
def fileDirectory():
    #Asks the user for a file root directory
    fileroot = raw_input("Please input the file root directory \n\n")

    #Returns a list with all the files inside the file root directory
    filelist = glob.glob(fileroot)
    print filelist
fileDirectory()

The next thing is that glob returns a the results of a glob - it doesn't list a directory, which appears to be what you're trying to do.

Either you want os.listdir, or os.walk or you actually should ask for a glob expression rather than a directory.

Finally raw_input might give you some extra whitespace that you'll have to strip off. Check what fileroot is.

You might want to split up your program, so that you can investigate each function separately.

Douglas Leeder
Hi, but when i tried using list.dir i get a error which says, " WindowsError:[Error 123], the filename, directory name, or volume label syntax is incorrect:'"/*.*', is there something wrong with my code?
Tom
Is the input you gave to glob actually "/*.*"? I think that may not be a valid path at all when running on Windows.
Domingo Galdos
Sounds like you are actually using a glob - in which case your variable names and comments are misleading.
Douglas Leeder
I would suggest trying the various pieces of functionality separately. In particular python glob module is unix-like expansions, so C:\* would get everything at the top level of C: (I think anyway).
Douglas Leeder