# New to custom code functions: Python default example doesn't work.

**URL:** <https://community.hubspot.com/t/new-to-custom-code-functions-python-default-example-doesnt-work/117828>\
**Category:** CMS Development\
**Tags:** professional\
**Created:** [October 7, 2024, 8:32pm UTC](https://community.hubspot.com/t/new-to-custom-code-functions-python-default-example-doesnt-work/117828 "2024-10-07T20:32:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CGrove0](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@CGrove0](https://community.hubspot.com/u/CGrove0)\
**Post date:** [October 7, 2024, 8:32pm UTC](https://community.hubspot.com/t/new-to-custom-code-functions-python-default-example-doesnt-work/117828/1 "2024-10-07T20:32:00Z")

</div>

Hi, I’m new to using the custom code function and when I test the default code block it gives when selecting python as the language it fails, but when I test with the custom JS block it works.

The JS code is here:

exports.main = async (event, callback) =\> {  
/\*\*\*\*\*  
Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.  
\*\*\*\*\*/  
const email = event.inputFields[‘email’];  
/\*\*\*\*\*  
Use the callback function to output data that can be used in later actions in your workflow.  
\*\*\*\*\*/  
callback({  
outputFields: {  
email: email  
}  
});  
}

The python code is here:

def main(event):  
email = event[“inputFields”][“email”]  
# Return the output data that can be used in later actions in your workflow.  
return {  
“outputFields”: {  
“email”: email  
}  
}

The python code fails with this message:

```auto
LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html
[ERROR] KeyError: 'email'
Traceback (most recent call last):
  File "/var/task/hubspotHandler.py", line 6, in hubspot_handler
    return file.main(event)
  File "/var/task/file.py", line 3, in main
    email = event["inputFields"]["email"]
Memory: 31/128 MB
Runtime: 3.93 ms

```

---

<div class="post-metadata">

**Author:** ![SteveHTM](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stevehtm/32/22074_2.png) [@SteveHTM](https://community.hubspot.com/u/SteveHTM)\
**Post date:** [October 8, 2024, 12:14am UTC](https://community.hubspot.com/t/new-to-custom-code-functions-python-default-example-doesnt-work/117828/2 "2024-10-08T00:14:08Z")

</div>

@CGrove0 - this may seem like a stupid question, but have you explicityly defined ‘email’ as an input property to the custom cose workflow step? The name must be an exact match to that input definition.

Steve
