Consider the following minimal working example:
---
title: "MWE"
author: "Raniere Silva"
date: "13/12/2021"
output: html_document
---
```{python}
def mwe(a, b):
if a > b:
out = 'foo'
elif a < b:
out = 'bar'
else:
out = 'none
return out
mwe(1, 2)
```
When I click in the "Run Current Chunk" in RStudio 1.4.1106, I get the following in the console:
> reticulate::repl_python()
Python 3.9.7 (/home/raniere/anaconda3/envs/faxitron/bin/python)
Reticulate 1.22 REPL -- A Python interpreter in R.
Enter 'exit' or 'quit' to exit the REPL and return to R.
>>> def mwe(a, b):
... if a > b:
... out = 'foo'
... elif a < b:
... out = 'bar'
... else:
... out = 'none
IndentationError: expected an indented block (<string>, line 6)
IndentationError: unexpected indent (<string>, line 1)
>>> return out
SyntaxError: 'return' outside function (<string>, line 1)
>>>
>>> mwe(1, 2)
NameError: name 'mwe' is not defined
>>>
Any recommendation on how to solve this issue?