# add_last_line_print

> **Function** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/tools/e2b_data_analysis/tool/add_last_line_print)

Add print statement to the last line if it's missing.

Sometimes, the LLM-generated code doesn't have `print(variable_name)`, instead the
    LLM tries to print the variable only by writing `variable_name` (as you would in
    REPL, for example).

This methods checks the AST of the generated Python code and adds the print
    statement to the last line if it's missing.

## Signature

```python
add_last_line_print(
    code: str,
) -> str
```

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/4b280287bd55b99b44db2dd849f02d66c89534d5/libs/community/langchain_community/tools/e2b_data_analysis/tool.py#L46)