Skip to content

Python code snippet – How to print variables in a string ?

name = "Steven"

# Using f-strings
print(f"Hi, {name}!")

# Using format()
print("Hi, {}!".format(name))
See also  How to put comments in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.