We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
str.format() is one of the string formatting methods in Python3, which allows multiple substitutions and value formatting. This method lets us concatenate elements within a string through positional formatting.\
Ex::
print ("{}, A computer science portal for geeks."
.format("GeeksforGeeks"))
str = "This article is written in {}"
print (str.format("Python"))
print ("Hello, I am {} years old !".format(18))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
String Formatting
You are viewing a single comment's thread. Return to all comments →
str.format() is one of the string formatting methods in Python3, which allows multiple substitutions and value formatting. This method lets us concatenate elements within a string through positional formatting.\ Ex:: print ("{}, A computer science portal for geeks." .format("GeeksforGeeks"))
str = "This article is written in {}" print (str.format("Python"))
print ("Hello, I am {} years old !".format(18))