388 - Use of Replacement field operator {} on strings
Use of Replacement field operator {} on strings
Example - 01 :
name , age = 'Rambo',50
print('Hello {0} , your age is {1}'.format(name,age))
output:
Hello Rambo , your age is 50
Example - 02 :
name , age = 'Rambo',50
print('Hello {n}, your age is {a}'.format(n=name,a=age) )
output:
Hello Rambo, your age is 50
Example - 03 :
name , age = 'Rambo',50
print('Hello %s, your age is %.2f'%(name,age))
output:
Hello Rambo , your age is 50
No comments:
Post a Comment