# Troubles with adressing elements of lists

**URL:** https://forum.robotframework.org/t/troubles-with-adressing-elements-of-lists/7995
**Category:** Robot Framework
**Created:** [22 October 2024 11:35 UTC](https://forum.robotframework.org/t/troubles-with-adressing-elements-of-lists/7995 "2024-10-22T11:35:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![janwouter](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@janwouter](https://forum.robotframework.org/u/janwouter)
#### Post date: [22 October 2024 11:35 UTC](https://forum.robotframework.org/t/troubles-with-adressing-elements-of-lists/7995/1 "2024-10-22T11:35:04Z")

</div>

Hi everyone. I’ve been running into the following error. Ive go this list with a couple of value pairs.  
I need to adress the second value of each pair, but I cannot figure out how. Can somebody please help.

```
***Settings***
Library Collections

***Variables***
@{mbas} ['DEEL1-A', 'DEEL2-A'] ['DEEL1-B', 'DEEL2-B']
 
***Test Cases***
MBA uitzoeken
    FOR ${mba} IN @{mbas}
        Log ${mba}
        ${first_element}= Set Variable ${mba[0]}
    END

```

---

<div class="post-metadata">

### Author: ![FrancisG](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/francisg/32/4247_2.png) [@FrancisG](https://forum.robotframework.org/u/FrancisG)
#### Post date: [22 October 2024 12:15 UTC](https://forum.robotframework.org/t/troubles-with-adressing-elements-of-lists/7995/2 "2024-10-22T12:15:25Z")

</div>

Your list variable is actually defined as a list of 2 string elements in the example you provided.

Here is a proper way to define a list of list, using inline python:  
`@{mbas} ${{['DEEL1-A', 'DEEL2-A']}} ${{['DEEL1-B', 'DEEL2-B']}}`  
It would also be possible to define the sublist in other variables, then use these variables to define the top list.

Otherwise, you have the [proper syntax](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#accessing-list-and-dictionary-items) to get the first element of each item of the list `${mba[0]}`.  
The second element is available as `${mba[1]}`.  
Note that this other syntax works too: `${mba}[1]`

Check it out on the [online playground](https://robotframework.org/code/?codeProject=N4IgdghgtgpiBcIDCBXAzgFwPZQAQGMsATOAGhBLXwCcBLABw1qzARBHIDNaAbGNBAG1Q3PgDlocRBn4YAdNSwAjLBg4hCYGVrYAqfbgDKMDEzABzNLn26AOmAAytJdQjUAnri-efuJFh4+fCYWNHt7G1wANTdaCCU+Kxt7AGJcAAFgKCUINABfX0LBAHIAEQBRcocARgBaAEFi0lwyyocAJgbigF0fEoqquoAhJpaBjtqR7vtM7NyCwp8AEmBgfra6xubWqs7G7ryFrxW1nZrJ0bPOqcP7XAiDABVZP1z+a317AFkh+twUWgYABeWBgAGsYGA7t4AGIAeQASsssjkjrgAJJiHyzHL5aGFBxYczIuZ5fG+FbcaiYAD6MD4sC0eQAvD5jBhorF4nwSajBAAGaZgRa4FZoGCaIh0hmQjAstkmTl0bkwXkQQTVA7k8piUogPLdcgkOgANxgRAACooAFYStTwTgQHji8iKFQYKIwanMViIADscmqgfUbtU9WolgQwDyrpgAEcAdQYIyMAJ4IIDkA).

Also note a new [VAR syntax](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#var-syntax) is available in RF 7, to replace `Set Variable`. And that you can update your existing tests and keyword automatically using tidy [ReplaceWithVAR](https://robotidy.readthedocs.io/en/stable/transformers/ReplaceWithVAR.html) transformer
