Sign in to follow this  
shanenin

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

Share this post


Link to post
Share on other sites

I feel stupid. I was trying to use the info that I returned in the function with the varaible name used in the function

wrong way

print dir_list

correct way

print movie_find()

Share this post


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...
Sign in to follow this