Did You Know — Adding = After an Expression in a Python f-string

# eg. f’{x=}’ returns ‘x=<value_of_x>’

Liu Zuo Lin
Level Up Coding
Published in
2 min readFeb 20, 2024

--

name, age = 'tom', 30

print(f'{name} {age}')
# tom 30

^ what happens when we use formatted strings normally

name, age = 'tom', 30

print(f'{name=} {age=}')
# name=tom age=30

--

--