# What is item.strip().split()\[0\] ?

**URL:** <https://forum.ansible.com/t/what-is-item-strip-split-0/24996>\
**Category:** Ansible Project\
**Created:** [July 15, 2017, 5:53pm UTC](https://forum.ansible.com/t/what-is-item-strip-split-0/24996 "2017-07-15T17:53:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnsibleGuy1](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@AnsibleGuy1](https://forum.ansible.com/u/AnsibleGuy1)\
**Post date:** [July 15, 2017, 5:53pm UTC](https://forum.ansible.com/t/what-is-item-strip-split-0/24996/1 "2017-07-15T17:53:37Z")

</div>

May I know what is " item.strip().split()[0] " mean in below code? I'm thining, first value in a space seperated line. Ref: https://github.com/geerlingguy/ansible-role-nfs/blob/master/tasks/main.yml - name: Ensure directories to export exist

file:'path="{{ item.strip().split()[0] }}" state=directory'

| 

with\_items: “{{ nfs\_exports }}” notify: restart nfs

 |
| | |

---

<div class="post-metadata">

**Author:** ![Mathias\_Ettinger](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mathias\_Ettinger](https://forum.ansible.com/u/Mathias_Ettinger)\
**Post date:** [July 17, 2017, 11:31am UTC](https://forum.ansible.com/t/what-is-item-strip-split-0/24996/2 "2017-07-17T11:31:58Z")

</div>

Almost. It’s the first value in a whitespace separated line, which means ‘foo bar’ and ‘foo\n \tbar’ would both be splitted to [‘foo’, ‘bar’] and element 0 is ‘foo’ for both.

On a side note, split() without arguments has extra logic that make the call to strip() redundant.

Lastly, nfs\_exports is a list defined as empty by default in [https://github.com/geerlingguy/ansible-role-nfs/blob/master/defaults/main.yml](https://github.com/geerlingguy/ansible-role-nfs/blob/master/defaults/main.yml). You may want to populate it by other means when running the playbook.

---

<div class="post-metadata">

**Author:** ![Arbab\_Nazar1](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@Arbab\_Nazar1](https://forum.ansible.com/u/Arbab_Nazar1)\
**Post date:** [July 17, 2017, 2:58pm UTC](https://forum.ansible.com/t/what-is-item-strip-split-0/24996/3 "2017-07-17T14:58:27Z")

</div>

You can check the readme file of the role and take the example from there and create small playbook like this:

`
