Fix Python – String formatting: % vs. .format vs. f-string literal

There are various string formatting methods:

Python <2.6: "Hello %s" % name Python 2.6+: "Hello {}".format(name)   (uses str.format) Python 3.6+: f"{name}"   (uses f-strings) Which is better, and for what situations? The following methods have the same outcome, so what is the difference? name = "Alice" "Hello %s" % name "Hello {0}".format(nam....