cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
saurabhtalele
Helper I
Helper I

Running python in power automate desktop error

Respexted sir , 

    i am new to power automate I have problem with getting wrong output from python in desktop automate.

 

k="""%NewVar2%"""

o="""%List3%"""

len([each for each  in o  if each.lower() in k.lower()])>=2

 

case : 1
NewVar2    is  variable as= Ram shyam sam

List3=["Ram","shyam"]

##################### Got Output in power automate as True

##################### Got Output in Python True

 

case : 2
NewVar2    is  variable as= Ram shyam sam

List3=["Rama","ashyam"]

##################### Got Output in power automate as True

##################### Got Output in Python as False

 

 

Why ? my output is differ from original in python ide,

I need that true or false produced by python 

Can I get that output somehow?

So tried thing like

 

k="""%NewVar2%"""

o="""%List3%"""

kk=len([each for each  in o  if each.lower() in k.lower()])>=2

print(kk)

 

 

but this is also not working?

 

thanks

your faithfully

saurabh

5 ACCEPTED SOLUTIONS

Accepted Solutions
iamspyder
New Member

Try This,

 

k="""%FileContents%"""
o=['ram','shyam']

kk=len([each for each  in o  if each.lower() in k.lower()])>=2
print(kk)

View solution in original post

dipakbadgujar
Frequent Visitor

Hi Saurabh,

You are getting this error because Python script can't be understand by Power Automate List or vice-versa.

Hence, you need to try following steps

 

 

k="""%NewVar2%"""


o=['ramm','shyam']


kk=[]

kkj=len([each for each  in o  if each.lower() in k.lower()])>=2

kk.append(kkj)

kk.append("true")
print(kk)

1.png2.png3.png4.png5.0.png6.png

View solution in original post

thanks this is also nice solution

View solution in original post

Rushikesh_98
New Member

k="""%NewVar2%"""


str="""%List3%"""

kk=str.lstrip("[").rstrip("]")

o=kk.split(',')

kk=[]

kkj=len([each for each  in o  if each.lower() in k.lower()])>=2

kk.append(kkj)

kk.append("true")
print(kk)

View solution in original post

nice solution sir,this best thing when python returns array

View solution in original post

6 REPLIES 6
iamspyder
New Member

Try This,

 

k="""%FileContents%"""
o=['ram','shyam']

kk=len([each for each  in o  if each.lower() in k.lower()])>=2
print(kk)

dipakbadgujar
Frequent Visitor

Hi Saurabh,

You are getting this error because Python script can't be understand by Power Automate List or vice-versa.

Hence, you need to try following steps

 

 

k="""%NewVar2%"""


o=['ramm','shyam']


kk=[]

kkj=len([each for each  in o  if each.lower() in k.lower()])>=2

kk.append(kkj)

kk.append("true")
print(kk)

1.png2.png3.png4.png5.0.png6.png

thanks this is also nice solution

Rushikesh_98
New Member

k="""%NewVar2%"""


str="""%List3%"""

kk=str.lstrip("[").rstrip("]")

o=kk.split(',')

kk=[]

kkj=len([each for each  in o  if each.lower() in k.lower()])>=2

kk.append(kkj)

kk.append("true")
print(kk)

Yes this is nice solution.....also

nice solution sir,this best thing when python returns array

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Top Solution Authors
Top Kudoed Authors
Users online (3,095)