How to correctly return an a dictionary as an output in zappier code using python

0 votes

I followed Zapier code documentation for Python but I'm still having this issue:

Objective:

I'm trying reformat my input(Feets) from Acuity Scheduling and update it on Salesforce.

Code:

if " ' " in input_data['Feets']:
output = {'Feets':Feets.split("'")[0],'Inches':Feets.split("'")[1]}
else
output = {'Feets':Feets,'Inches':Inches}
Dec 3, 2018 in Python by aryya
• 7,440 points
929 views

1 answer to this question.

0 votes

David here, from the Zapier Platform team. You've got two issues:

  1. You're missing a : for your else, causing the python to not parse correctly
  2. In your if, you don't want spaces around the "'"
  3. You need to read input from the input_data dict

The following code works as expected:

if "'" in input_data['Feets']:
    output = {'Feets': input_data['Feets'].split("'")[0], 'Inches': input_data['Feets'].split("'")[1]}
else:
    output = {'Feets': input_data['Feets'],'Inches': input_data['Inches']}
answered Dec 3, 2018 by charlie_brown
• 7,710 points

Related Questions In Python

0 votes
0 answers

How to return dictionary keys as a list in Python?

Now, in Python >= 3.3, I get something ...READ MORE

Feb 18 in Python by Dev
• 6,000 points
62 views
0 votes
1 answer

How to write a code In Python where input will be 1 then the output will be 2?

You can go through this:  def num(number): ...READ MORE

answered Oct 7, 2020 in Python by Gitika
• 65,890 points
317 views
0 votes
3 answers

how to exit a python script in an if statement

In Python, the break statement provides you with the opportunity ...READ MORE

answered Dec 14, 2020 in Python by Roshni
• 10,520 points
282,656 views
0 votes
1 answer

How to convert an integer to a string using Python?

Here is an easy solution: def numberToBase(n, b): ...READ MORE

answered Nov 23, 2018 in Python by Nymeria
• 3,560 points

edited Dec 12, 2018 by Nymeria 465 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 3,152 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
2,358 views
+2 votes
2 answers

How to make a laplacian pyramid using OpenCV python?

down voteacceptTheeThe problem is that you're iterating ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,710 points
3,938 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP