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,320 points
70 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
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
• 14,980 points
420 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,500 points

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

edited Dec 10, 2018 by Nymeria 61 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,500 points

edited Dec 19, 2018 by Nymeria 5,067 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
55 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,710 points
1,013 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.