I'm currently working on a python bot that references variables from different users based on the input from the user. The user enters in the name of a file in the folder, which has a list saved to it. All of the files have the same list name, but each list has different elements saved. The idea is that the files act as accounts for the user, and each one has its own keys saved in the list.
I want to then set a variable to the contents of the list from whatever file the user selected, like so:
import file1
import file2
import file3
filePath = input()
fileContents = filePath.list
This displays an error because the filePath
variable is technically a string and does not have a list
attribute.
My question is:
How can I set fileContents
to the contents of the list that the user chosen file contains?