python get latest edited file from any directory

from os.path import expanduser
import os
home = expanduser("~")
latest_edited_folder = max([f for f in os.scandir(home)], key=lambda x: x.stat().st_mtime).name
search_on = home+'\\'+latest_edited_folder
latest_edited_file = max([f for f in os.scandir(search_on)], key=lambda x: x.stat().st_mtime).name

Here is what the above code is Doing:
1. It’s getting the home directory of the user.
2. It’s getting the latest edited folder in the home directory.
3. It’s getting the latest edited file in the latest edited folder.