How do I get background colors assigned to certain words and punctuation marks? I want it like in the following picture:

Here is my code:
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{listings}
\usepackage{xcolor}
\def\tikzmark#1{\tikz[remember picture,overlay]\nodeyshift=2pt{};}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
escapeinside={}{},
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=mystyle}
\usepackage[absolute,overlay]{textpos}
\newcommand\PlaceText[3]{%
\begin{textblock}{10in}(#1,#2) %% change width of box from 10in as you wish
#3
\end{textblock}
}%
\begin{document}
\begin{lstlisting}[language=Python]
Here is the function:
def hello():\tikzmark{A}
print("Hello together!")
Main:
hello() \tikzmark{B}
hello() \tikzmark{C}
hello() \tikzmark{D}
\end{lstlisting}
\tikzset{Empharrow/.style={dashed,red,thick,->,arrows={-Triangle[width=3pt]}}}
\begin{tikzpicture}[remember picture,overlay]
\drawEmpharrow--+(7cm,0)|-(A);
\drawEmpharrow--+(6cm,0)|-(A);
\drawEmpharrow--+(5.5cm,0)|-(A);
\end{tikzpicture}
\PlaceText{100mm}{60mm}{The \texttt{hello()} function is called here}
\end{document}
Output:
Is there a more elegant way? Nonetheless, my main concern is the background color of certain words in the code.


tikzmarklibrary if you don't want to automatize it. Otherwise, you'll have to find a way to add backgrounds onlistings, which I don't know how to do... yet. – SebGlav May 14 '23 at 21:24tikzmarkandlistingslibraries work together, but it's not possible to colour some words this way. Not sure this is the best way to do this. Maybe Andrew Stacey could give some help on that. – SebGlav May 15 '23 at 17:32