DAY 25(CODE INFINITY)
Hii everyone a new day in our life with this beautiful day Let's start a new topic string formatting as the topic name suggests we have to format the string and this can be done using two method :
1. format method
2. f-strings
f-string can be formatted in much same as str.format() means format method syntax is simple for both methods so Let's get started...
Format method:
details = "I am {} from{}"
name = "Shweta"
state = "Haryana"
print(details.format(name,state))
f-strings
details = "I am {} from{}"
name = "Shweta"
state = "Haryana"
print(f"I am {name} from {state}")
if we want to print the value of the variable in the string then you can use the double curly brackets
let me show you how to write this
Comments