2

I want to create a variable that's value is the name of the folder that I am working in. I can use pwd to see the working directory but I cannot figure out if there is a way to save the pwd output as a variable or better yet make a variable with only the current folder not the entire directory.

Alison S
  • 43
  • 3

1 Answers1

1

Here is one method:

#!/usr/bin/env python2.7

import os

current_folder = os.getcwd().split(os.sep)[-1]

print(current_folder)
Fake Code Monkey Rashid
  • 13,731
  • 6
  • 37
  • 41