Using Return In Function


Recommended Posts

I have this function below

def movie_find():    
   import os
   import string

   ls_dir = os.listdir('/home/shane/freevo/movies')
   dir_list =[]
   for i in ls_dir:
       if string.find(i,'.mp4') != -1:
    if i[0] != '.':
        if string.find(i,'.conf') == -1:
         dir_list.append(i)
       if string.find(i,'.avi') != -1:
    if string.find(i,'.conf') == -1:
        dir_list.append(i)

how do I use the return so I am able to use the list called dir_list out side of the function.

I have tried adding

return dir_list

to the function, but that does not seem to help

Edited by shanenin
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...