Sponsored By

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this