How to Use a Variable from List in a Loop

Hi,

I need to make a Loop from a List where every time it works it takes an item from a list.

I don’t know to do this.

I think my problem is clear in this PrintScreen.

@Shark - Your “item” in the for each loop contains the values of Item1 and Item2 while looping.

To see it, Remove the Assign and add a write Line --> item

Once the loop completes, you will see an output of

Item1
Item2

Hope this helps.

Thanks, man.

Sorry for my ignorance, but it seems it doesn’t work.
What I need is the variable named ‘Account’ be defined by each item in ‘AccountList’ in every loop.

What is your For Each Type…If its not String…Change it to String Or Put Item.tostring(if For Each type Is Object)

and instead of +Account…modify +Item or +Item.toString(if For Each type Is Object)

Please check this video

2 Likes

That is because you have to either use the object type or convert the item to string value.

Solution alternative 1:

item.ToString

You can keep the TypeArgument as Object.

Solution alternative 2: item
Or if you already declared that item in your For Each will be a string. Then you do not need to say item.ToString in your for loop.

UsingListinForEach.xaml (8.6 KB)

1 Like

Thanks, man… it works!

Hi Shark,

While using for each loop, you can use that item element in the loop, it will give access to each element in each iteration in the list.

Suppose in your chrome url you can use :
“google.com++profile+directory=”+item

Hope it helps,

Regards,
Sahil Garg