print(f"Current score: {U}/{L}")
Strings enclosed with simple quotes or double-quotes imply that all characters in it are just literal text - they are not interpreted as variables.
From Python 3.6, the prefix f
for the quotes delimiting the string denotes an special literal which can include Python expressions inside - including variables. Still, to separate these variables from plain text (and avoid unpredictable substitutions), these expressions have to be further delimited by { }
, inside the string.
Prior to Python 3.6, one would have to do it in two separate steps: create a plain string with special markers were the variables contents would be inserted, and then call the .format
method on the string. (or, there is an older method using the %
operator instead). Fully documenting these other methods would be long - but a short form would require one to write:
print("Current score: {}/{}".format(U, L))