Fish Touching🐟🎣

Python F-string

Nov 3, 2022

# Python F-string

Formatted string literals (also called f-strings for short)

# Alignment

Approach : The syntax of the alignment of the output string is defined by <, >, ^ and followed by the width number
Example 1 : For Left Alignment output string syntax define β€˜<β€˜ followed by the width number.
print(f"{'Left Aligned Text' : <20}")
Example 2 : For Right Alignment output string syntax define β€˜>’ followed by the width number.
print(f"{'Right Aligned Text' : >20}")
Example 3 : For Center Alignment output string syntax define β€˜^’ followed by the width number.
print(f"{'Centered' : ^10}")