web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to use Python list...
Power Automate
Unanswered

How to use Python list value in 'Run Python Script'?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello.

I have a question to using Power Automate Desktop.

I find flow called 'Run Python Script'

So, I tried to use this. but one problem (maybe..?one?)

PAD's value in List is not defined to python script.

How to use this 'List value'?

I think my python grammar is OK.

Sorry to my English 

cause, PAD Tool got 'Run Python Script' Flow....

plz help me 😞

 

 

Here is the my problem

 

Traceback (most recent call last):
File "<string>", line 5, in <module>
NameError: name 'test0' is not defined

 

My List1 = listman.PNG

 

my python script
6666.PNG

Power Automate free license limitations 

I have the same question (0)
  • ZS440 Profile Picture
    262 on at
  • fraenK Profile Picture
    2,125 on at

    %List1[cnt]% returns the string test0, so you're missing the quotation marks around %List1[cnt]% in line 5

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Anonymous 

     

    I faced the same problem, when you pass a variable into a python list from PAD list or datatable it comes without " double quotes ... so you have to add them manually before appending the value to the list

     

    --> See my post below <--

     

  • fraenK Profile Picture
    2,125 on at

    Sorry, but this "issue" here is totally different than yours 😉

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I modified my reply... but this is also related to my issue

    https://powerusers.microsoft.com/t5/Power-Automate-Desktop/Custom-variable-index-within-a-Python-VBA-Javascript-script/m-p/862418#M2126

    Because the list and datatables comes with plain text without double quotes on string... so assignign the list or datatable to a python variable (like you reply on my post) it is not working!! for the same concept of this question

     

    I was meaning that! Thanks

     

    @fraenK 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Anonymous 

     

    I got the solution 🙂 you have to transform your list before in text, by adding the " double quotes... so doing this way:

     

    You have your LIST1:

    listman.PNG

    Before executing the python script, you have to create a text variable structured as python list. So in this way:

    Capture.PNG

    The ouput would be this:

     

     

    test0","test1","test2","test3","test4","test5

     

     

     

    Now you have the python script, but you have to add the square brackets before and after the list, to have this

     

    ["test0","test1","test2","test3","test4","test5"]

     

    So the python code is

     

    List1_new = %'[\"' + JoinedText + '\"]'%
    testa = %cnt%
    testb = []
    cntt = 0
    for k in range(3):
     testb.append(List1_new[%cnt%])
     cnt+=1
    ......
    ......

     

    Let me know if it works 😉 

     

    PS. If you have numbers on list, you have to find a way to cast them before to use them in python

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 253 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 172 Super User 2026 Season 2

#3
trice602 Profile Picture

trice602 134 Super User 2026 Season 2

Last 30 days Overall leaderboard