0

I'm trying to create a directory of folders and files for each user, and I can't seem to access a dictionary for a folder within a list of all of a user's files but only using the folder name, not by indexing.

I could iterate over the list and check if the element is a dictionary with the folder name I'm trying to access, but I felt like there was probably an easier way.

userDir = {"User1": [{"folder1": [file1, file2]}, file3], "User2": []}

What's the best way I could access the dictionary key "folder1" here?

Roger Wang
  • 513
  • 1
  • 8
  • 27

0 Answers0