less than 1 minute read

f string

f string is new cocept.
Similar with Ruby’s #{} thing.
Can put function inside of {}.

name = " eric "
print(f"Hello, {name.strip()} would you like to learn some Python today?")

print(name.lower())
print(name.upper())
print(name.title())

harry = f"{name.title().strip()} Differences of habit \nand language are nothing at all \n\tif our aims are identical \n\tand our hearts are open"
print(harry)

Multiple Assignment

In python, we can assign

x, y, z = 0, 0, 0

first_name, last_name = "harry", "potter"

print(first_name.upper())
# HARRY

Categories:

Updated: