I need to create directories from for loop. I have a list.

```
a = [banana 1234, apple 456, orange 789]

```

And I need to create folders named by the numbers that are ending with numbers in list. for example. 

```
C:\folder\1234; C:\folder\456

```

and so on. 

code is 

```
for length in atrinkta:
folder = re.findall(r'\d{9,}', length)
os.makedirs("D:/python_study/images/skelbimai/" + folder)

```

but I get an error **"TypeError: cannot concatenate 'str' and 'list' objects"** don't know what to do. Please someone help.

**EDIT**
I tried your method 2nd time. After deleting created folder for whatever reason python gives me error

```
WindowsError: [Error 183] Cannot create a file when that file already exists: 'D:/python_study/images/skelbimai/'

```

**2ndEdit**

shaktimaan, now i get other error **AttributeError: 'NoneType' object has no attribute 'group'**. What does this mean?
['https://Stackoverflow.com/questions/23201713', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3383245/']
You will receive the following error

```
undefined method `collect' for nil:NilClass

```

on

```
<%= f.select :id , @courses.collect{|c| [c.id , c.name]} %>

```

Only when `@courses` instance variable **was not set in the action that rendered this particular view.** 

I see that `@courses` variable is set in the `existing` method. If you are using `existing` as an action which renders this view then your view name must be `existing.html.erb`.

Or if you are rendering the view from a different action then in that case you should set `@courses` value in that particular action by either directly setting the value within action OR by calling `existing` method from there.
If you have your courses as a database table, you might want to try using rails' built in field helper `collection_select`. It will populate your select field with all of the data available in your model. If you want a drop-down like the one you are describing, I believe using collection select is the best way to handle it. 

You can read up on it here: <http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html>

Alternatively, if you have a ton of courses, maybe try looking into using a text field with autocomplete. Jquery UI has a plugin that makes this very easy. You can check out the railscasts for it here: <http://railscasts.com/episodes/102-auto-complete-association-revised>.

It requires a pro account but if you do a lot of rails developing it will be the best $9 you spend every month.

If you would like to continue to do it this way, make sure that you are defining 
`@courses = Courses(:all)` in the correct controller action, otherwise you will have nothing to render.