Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python for File Systems Manipulation Purging

I don't understand this?

Now create a second function named delete_by_user that works similarly but deletes files that have a particular username in their filename.

purging.py
import os

def delete_by_date(date):
    for f in os.listdir(os.getcwd() + '/backups'):
        if date in f:
            os.remove('backups/' + f)
Dave Faliskie
Dave Faliskie
17,793 Points

It want's another function called delete_by_user() that is the same except instead of date it uses the username, so you could just copy/past what you have and rename the function, and change date to username (but don't even have to do that)

2 Answers

Steven Parker
Steven Parker
231,275 Points

Actually, the way you've implemented the first function will work for the second task as well. Just replicate the function and give the new copy the other name. :wink: