Tags
python
Asked 1 years ago
24 Apr 2023
Views 282
sandip

sandip posted

what means {0} in Python ?

how to use uses {0} in a string at Python?


kord

kord
answered Jun 29 '23 00:00

{0} is used with the format() method to put values into a string dynamically.
for example

adjective= "language"
totalmethod = 25
message = "Python is good  {0} , which have {1} methods ".format(name, totalmethod )
print(message)


will output like this
Python is good language , which have 25 methods

here {0} and {1} is work as placeholder for corresponding variable passed in format method

you can use any number of placeholder with same number of corresponding variable at format method.
Rasi

Rasi
answered Jun 29 '23 00:00

it used to create dynamic strings by substituting variables or values into specific positions within the string
Post Answer