On 06/03/17 01:33, Rafael Skovron wrote: > This project compares two text files with parcel numbers. I think I'm > messing up the function call. I'm getting this error: > > Traceback (most recent call last): > File "amador.py", line 48, in <module> > remaining_parcels(auctionlist,removedlist) > NameError: name 'auctionlist' is not defined >
Your subject line is correct - it is a scope issue. > fname = 'saclisting.txt' > removed = 'removed.txt' > > def get_parcel_number(fname): > pattern = r'^(\d{3})-(\d{3})-(\d{3})-(\d{3})' > auctionlist = [] Here you create a local variable auctionlist. local variables only exist within the function that creates them. > return auctionlist You return the auctionlist object from the function but.... > > get_parcel_number(fname) You never store the returned object so it gets destroyed. > get_removed_number(removed) > remaining_parcels(auctionlist,removedlist) Now you try calling this function with auctionlist as an argument but thee is no such variable (it only existed inside the first function). You need to store the result of the first function and use that stored value in this function call. HTH -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor