Looping through directories in Python using f-string

I am trying to access 2 different directories in ADLS using for loop & f-string but facing issues in doing so

# Primary storage info
 account_name = "accountnamehere"  # fill in your primary account name
 container_name = "logscontainer"  # fill in your container name
 subscription_id = "subscriptionname"
 resource_group = "My-Resource-ML" # fill in your resource gropup for ADLS account
 workspace_name = "My-Workspace-ML" # fill in your la workspace name

 datasets=[test1,test2]
 for df in datasets :
    input_path = f"datasets"
    print(input_path)

I get the following error

----> 8 datasets=[{test1},{test2}]
      9 for df in datasets :
     10     input_path = f"datasets"

NameError: name ‘test1’ is not defined

Can someone help ?

>Solution :

How about the following:

datasets = ['test1', 'test2']
for df in datasets:
    input_path = f"{df}/subdirectory"

?

Leave a Reply