python f string multiline code example
Example 1: multiline f string python
date = "01/31/1956"
time = "9:30 AM"
tags = ["high value", "high cost"]
text = "Hello"
return (
f'{date} - {time}\n'
f'Tags: {tags}\n'
f'Text: {text}'
)
return f'''{date} - {time},
Tags: {tags},
Text: {text}
'''
Example 2: python f string
>>> name = "Eric"
>>> age = 74
>>> f"Hello, {name}. You are {age}."
'Hello, Eric. You are 74.'
Example 3: python fstring
age = 12
name = "Simon"
print(f"Hi! My name is {name} and I am {age} years old")