Question: I use this code for create folder for users:

```
work_path = '/tmp/'

os.umask(0000)
for i in user:
    if not os.path.exists(work_path + i):
        try:
               os.makedirs(work_path + i, 0777)

```

When I set work\_path = '/tmp/' - my code work perfect.
But when I type for mistake work\_path = '/tmp' I got not what expected )))

Question: how can I check my path have backslash, or maybe how can I create folders for another way ?

Answer: 
Use [os.path.join](https://docs.python.org/2/library/os.path.html#os.path.join):

> 
> Join one or more path components intelligently. The return value is the concatenation of path and any members of \*paths with exactly one directory separator (os.sep) following each non-empty part except the last, meaning that the result will only end in a separator if the last part is empty. If a component is an absolute path, all previous components are thrown away and joining continues from the absolute path component.
> 
> 
> 

```
os.makedirs(os.path.join(work_path,i))

```

So in your code join the path once then use the joined path:

```
for i in user:
    pth = os.path.join(work_path, i)
    if not os.path.exists(pth):
        try:
            os.makedirs(pth, 0777)

```
You can use just the expression

```
work_path[-1] == '/'

```

If it is true you have a backslash