python \n in f" print code example

Example 1: f string in python

# f-strings are short for formatted string like the following
# you can use the formatted string by two diffrent ways
# 1
name = "John Smith"
print(f"Hello, {name}")		# output = Hello, John Smith

# 2
name = "John Smith"
print("Hello, {}".format(name))		# output = Hello, John Smith

Example 2: f-string expression part cannot include a backslash

This is specified in the PEP for f-strings:
Backslashes may not appear inside the expression portions of f-strings, [...]

One option is assinging '\n' to a name and then .join on that inside the f-string; that is, without using a literal:
Example:
names = ['Adam', 'Bob', 'Cyril']
nl = '\n'
text = f"Winners are:{nl}{nl.join(names)}"
print(text)