Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

.format() multiple placeholders

# Python program using multiple place
# holders to demonstrate str.format() method
 
# Multiple placeholders in format() function
my_string = "{}, is a {} science portal for {}"
print(my_string.format("GeeksforGeeks", "computer", "geeks"))
 
# different datatypes can be used in formatting
print("Hi ! My name is {} and I am {} years old"
      .format("User", 19))
 
# The values passed as parameters
# are replaced in order of their entry
print("This is {} {} {} {}"
      .format("one", "two", "three", "four"))

OUTPUT:
GeeksforGeeks, is a computer science portal for geeks
Hi! My name is User and I am 19 years old
This is one two three four
Comment

.format() multiple placeholders

# Python program using multiple place
# holders to demonstrate str.format() method
 
# Multiple placeholders in format() function
my_string = "{}, is a {} science portal for {}"
print(my_string.format("GeeksforGeeks", "computer", "geeks"))
 
# different datatypes can be used in formatting
print("Hi ! My name is {} and I am {} years old"
      .format("User", 19))
 
# The values passed as parameters
# are replaced in order of their entry
print("This is {} {} {} {}"
      .format("one", "two", "three", "four"))

OUTPUT:
GeeksforGeeks, is a computer science portal for geeks
Hi! My name is User and I am 19 years old
This is one two three four
Comment

.format() multiple placeholders

# Python program using multiple place
# holders to demonstrate str.format() method
 
# Multiple placeholders in format() function
my_string = "{}, is a {} science portal for {}"
print(my_string.format("GeeksforGeeks", "computer", "geeks"))
 
# different datatypes can be used in formatting
print("Hi ! My name is {} and I am {} years old"
      .format("User", 19))
 
# The values passed as parameters
# are replaced in order of their entry
print("This is {} {} {} {}"
      .format("one", "two", "three", "four"))

OUTPUT:
GeeksforGeeks, is a computer science portal for geeks
Hi! My name is User and I am 19 years old
This is one two three four
Comment

.format() multiple placeholders

# Python program using multiple place
# holders to demonstrate str.format() method
 
# Multiple placeholders in format() function
my_string = "{}, is a {} science portal for {}"
print(my_string.format("GeeksforGeeks", "computer", "geeks"))
 
# different datatypes can be used in formatting
print("Hi ! My name is {} and I am {} years old"
      .format("User", 19))
 
# The values passed as parameters
# are replaced in order of their entry
print("This is {} {} {} {}"
      .format("one", "two", "three", "four"))

OUTPUT:
GeeksforGeeks, is a computer science portal for geeks
Hi! My name is User and I am 19 years old
This is one two three four
Comment

.format() multiple placeholders

# Python program using multiple place
# holders to demonstrate str.format() method
 
# Multiple placeholders in format() function
my_string = "{}, is a {} science portal for {}"
print(my_string.format("GeeksforGeeks", "computer", "geeks"))
 
# different datatypes can be used in formatting
print("Hi ! My name is {} and I am {} years old"
      .format("User", 19))
 
# The values passed as parameters
# are replaced in order of their entry
print("This is {} {} {} {}"
      .format("one", "two", "three", "four"))

OUTPUT:
GeeksforGeeks, is a computer science portal for geeks
Hi! My name is User and I am 19 years old
This is one two three four
Comment

.format() multiple placeholders

# Python program using multiple place
# holders to demonstrate str.format() method
 
# Multiple placeholders in format() function
my_string = "{}, is a {} science portal for {}"
print(my_string.format("GeeksforGeeks", "computer", "geeks"))
 
# different datatypes can be used in formatting
print("Hi ! My name is {} and I am {} years old"
      .format("User", 19))
 
# The values passed as parameters
# are replaced in order of their entry
print("This is {} {} {} {}"
      .format("one", "two", "three", "four"))

OUTPUT:
GeeksforGeeks, is a computer science portal for geeks
Hi! My name is User and I am 19 years old
This is one two three four
Comment

.format() multiple placeholders

# Python program using multiple place
# holders to demonstrate str.format() method
 
# Multiple placeholders in format() function
my_string = "{}, is a {} science portal for {}"
print(my_string.format("GeeksforGeeks", "computer", "geeks"))
 
# different datatypes can be used in formatting
print("Hi ! My name is {} and I am {} years old"
      .format("User", 19))
 
# The values passed as parameters
# are replaced in order of their entry
print("This is {} {} {} {}"
      .format("one", "two", "three", "four"))

OUTPUT:
GeeksforGeeks, is a computer science portal for geeks
Hi! My name is User and I am 19 years old
This is one two three four
Comment

.format() multiple placeholders

# Python program using multiple place
# holders to demonstrate str.format() method
 
# Multiple placeholders in format() function
my_string = "{}, is a {} science portal for {}"
print(my_string.format("GeeksforGeeks", "computer", "geeks"))
 
# different datatypes can be used in formatting
print("Hi ! My name is {} and I am {} years old"
      .format("User", 19))
 
# The values passed as parameters
# are replaced in order of their entry
print("This is {} {} {} {}"
      .format("one", "two", "three", "four"))

OUTPUT:
GeeksforGeeks, is a computer science portal for geeks
Hi! My name is User and I am 19 years old
This is one two three four
Comment

.format() multiple placeholders

# Python program using multiple place
# holders to demonstrate str.format() method
 
# Multiple placeholders in format() function
my_string = "{}, is a {} science portal for {}"
print(my_string.format("GeeksforGeeks", "computer", "geeks"))
 
# different datatypes can be used in formatting
print("Hi ! My name is {} and I am {} years old"
      .format("User", 19))
 
# The values passed as parameters
# are replaced in order of their entry
print("This is {} {} {} {}"
      .format("one", "two", "three", "four"))

OUTPUT:
GeeksforGeeks, is a computer science portal for geeks
Hi! My name is User and I am 19 years old
This is one two three four
Comment

PREVIOUS NEXT
Code Example
Python :: # to check if the list is empty use len(l) or not 
Python :: # get documentation for module in terminal 
Python :: python abbreviated for loop 
Python :: how to solve differential equations in python 
Python :: python nltk lookup error Resource omw-1.4 not found. 
Python :: get dataframe deminsions 
Python :: pairplot hide original legend 
Python :: Default rows values display 
Python :: separating numeric and categorical feature using loop 
Python :: how to limit variable godot 
Python :: pyttsx3 Running a driver event loop 
Python :: logging errors into emails 
Python :: Find Factors of a Number Using Class 
Python :: select majority pandas 
Python :: Python 2 vs Python 3 Print Statement 
Python :: python print numbers with commas 
Python :: codeforces 1133A in python 
Python :: strain rate 
Python :: convert float array to integer 
Python :: ax text not placed correclty 
Python :: Python NumPy transpose Function Example with use of tuples 
Python :: with statement in python 
Python :: codeforces problem 200B 
Python :: making dividers in tkinter 
Python :: torch mean of tensor 
Python :: how to get defintiion of pysspark teable 
Python :: colorbar over two axes 
Python :: data base creation 
Python :: Python PEP (class) 
Python :: how to swap a lowercase character to uppercase in python 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =