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:


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


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

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]}
    output = {'Feets': input_data['Feets'],'Inches': input_data['Inches']}
answered Dec 3, 2018 by charlie_brown
• 7,700 points

Related Questions In Python

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,970 points
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,480 points
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,540 points

edited Dec 12, 2018 by Nymeria 320 views
0 votes
1 answer

How to use Pandas HDF5 as a Database in Python?

HDF5 works fine for concurrent read only ...READ MORE

answered Nov 30, 2018 in Python by Nymeria
• 3,540 points

edited Dec 10, 2018 by Nymeria 470 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 2,537 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,810 points
+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,700 points