# Syntax to access item in with\_sequence in a complex variable

**URL:** <https://forum.ansible.com/t/syntax-to-access-item-in-with-sequence-in-a-complex-variable/23110>\
**Category:** Ansible Project\
**Created:** [November 27, 2016, 5:54am UTC](https://forum.ansible.com/t/syntax-to-access-item-in-with-sequence-in-a-complex-variable/23110 "2016-11-27T05:54:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonheur.sorn](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@bonheur.sorn](https://forum.ansible.com/u/bonheur.sorn)\
**Post date:** [November 27, 2016, 5:54am UTC](https://forum.ansible.com/t/syntax-to-access-item-in-with-sequence-in-a-complex-variable/23110/1 "2016-11-27T05:54:54Z")

</div>

Hi everyone

I’m trying to use the item value in ‘with\_sequence’ to access an element in my array variable.

I understand that to access variables using the bracket syntax […] in

- vars =\> use vars[…]

- hostvars =\> use hostvars[…]

But how to access an item in with\_sequence using the bracket syntax […]?

`

---

<div class="post-metadata">

**Author:** ![bonheur.sorn](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@bonheur.sorn](https://forum.ansible.com/u/bonheur.sorn)\
**Post date:** [November 27, 2016, 6:06am UTC](https://forum.ansible.com/t/syntax-to-access-item-in-with-sequence-in-a-complex-variable/23110/2 "2016-11-27T06:06:46Z")

</div>

Ok I just found the right syntax… [item | int]

command: “{{ script\_path }}/send-commands.exp {{ mgmt\_prefix\_ip }}.{{ item | int + vars[‘mgmt\_start\_ip’] }} {{ username }} {{ password }} {{ config\_path }}/{{ vars[‘device’][item | int][‘hostname’] }}.txt”
