1

Iam trying to make folder 'trump' with subfolders 'pos','neg'.

folders=['pos','neg']
for folds in folders:
   os.makedirs['trump/{}'.format(folds)] 

Iam getting this error.Can anyone says how to do this?

           TypeError: 'function' object is not subscriptable
3
  • Use makedirs() instead of makedirs[] Commented Mar 14, 2018 at 6:06
  • BTW You can consider using os.path.join('trump',folds) to make your code less OS dependent Commented Mar 14, 2018 at 6:09
  • Thanks. That was a sily syntax error Commented Mar 14, 2018 at 6:11

1 Answer 1

1

Looks to be a simple syntax error

folders=['pos','neg']
for folds in folders:
   os.makedirs(os.join('trump', folds)) # function call with os.join

Edit: include sshashank124 suggestion

Sign up to request clarification or add additional context in comments.

2 Comments

Or os.sep instead
Thank you.It worked.Can anyone say y they downvoted this question so that I can improve it next time.Is it bcoz I mentioned trump?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.