Question

Python if statement not working

  • 28 July 2023
  • 1 reply
  • 196 views

Hello,

 

I am trying to write a simple python code in Zapier but for some reason the if statements fail even though they are exactly the same.

Here is my code:

output = {}

if operator.eq(input_data['step1'], '500-Mb-USD') or input_data['step1'] == '500-Mb-USD-Monthly' or input_data['step2'] == 'NIA_TURBO_500':
output['speed'] = 'NIA_TURBO-500'
elif input_data['step1'] == '1-Gig-USD' or input_data['step1'] == '1-Gig-USD-Monthly' or input_data['step2'] == 'NIA_INSANE_1000':
output['speed'] = 'NIA_INSANE_1000'
elif input_data['step1'] == '2-Gig-USD' or input_data['step1'] == '2-Gig-USD-Monthly' or input_data['step2'] == 'NIA_SUPREME_2000':
output['speed'] = 'NIA_SUPREME_2000'

return output

I have 2 input variables sent in, i KNOW that step1 is equaling ‘2-Gig-USD-Monthly’ and when i print step 1, it shows exactly what it should, but these statements fail, can someone point me in the right direction? I know Zapier uses a scraped down version of python, but I would think that basic if elif statements were acceptable.

 

Thank you for any help on this.


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Ok, despite me accidently leaving in a test (operator.eq) call, i found my issue, i had an empty space after the value in step1.. ugh.. so be careful when your grabbing the input_data values from zapier, an extra space can cause multiple hours of frustration.. lol