I have tried with both python 2.7.18 and python 3.8.6 using Emacs 27.1 and the excerpt works without issue for me; I have no configuration (emacs -Q) beyond pointing org to my virtual environment and allowing python evaluation in org-babel:
There have been a few different fixes around the "last line" return value over the years[0][1] but I can't really remember something like your example not working for me personally.
There have been a few different fixes around the "last line" return value over the years[0][1] but I can't really remember something like your example not working for me personally.
[0]: https://lists.gnu.org/archive/html/emacs-orgmode/2017-11/msg...
[1]: https://orgmode.org/list/[email protected]/t/#u