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 ariaholic
• 7,340 points
136 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,720 points

Related Questions In Python

0 votes
1 answer

how to exit a python script in an if statement

This works fine for me: while True: ...READ MORE

answered Sep 19, 2018 in Python by bug_seeker
• 15,350 points
4,359 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,520 points

edited Dec 12, 2018 by Nymeria 48 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,520 points

edited Dec 10, 2018 by Nymeria 115 views
0 votes
1 answer

How to get the return value from a thread using python?

You don't need to change your existing ...READ MORE

answered Dec 3, 2018 in Python by Nymeria
• 3,520 points

edited Dec 19, 2018 by Nymeria 13,933 views
+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 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 332 views
+4 votes
6 answers
0 votes
1 answer
+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,720 points
1,643 views