# Get indice in variable

**URL:** <https://forum.ansible.com/t/get-indice-in-variable/29825>\
**Category:** Ansible Project\
**Created:** [March 5, 2019, 8:53am UTC](https://forum.ansible.com/t/get-indice-in-variable/29825 "2019-03-05T08:53:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryad9200000](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@ryad9200000](https://forum.ansible.com/u/ryad9200000)\
**Post date:** [March 5, 2019, 8:53am UTC](https://forum.ansible.com/t/get-indice-in-variable/29825/1 "2019-03-05T08:53:08Z")

</div>

Hy all,

I have this task :

- set\_fact:  
liste\_appli: “{{ item.split(‘,’)[3:] }}”  
with\_lines: cat /home/ansible/ssh\_manager/clef\_applicatives.csv  
when: (item.split(‘,’)[1] == ansible\_user) and (item.split(‘,’)[2] == inventory\_hostname)  
delegate\_to: localhost

And i have this task who count number of element in variable liste\_appli:

- set\_fact:  
long\_liste: “{{ liste\_appli | length }}”

But content of **long\_liste** is only one number, or i want that this variable content all indice of my variable **liste\_appli.**

Exemple :

**liste\_appli** = “valeur1”, “valeur2”, “valeur3”

**long\_liste** = [0,1,2]

Someone have idea ?

Thank you very much guy !!

Regards

---

<div class="post-metadata">

**Author:** ![ryad9200000](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@ryad9200000](https://forum.ansible.com/u/ryad9200000)\
**Post date:** [March 5, 2019, 10:37am UTC](https://forum.ansible.com/t/get-indice-in-variable/29825/2 "2019-03-05T10:37:46Z")

</div>

Solved,
