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
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

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.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,225)