How can we give arguments in a string containing '{}'
? Example: string = "my age is '{}' years old'
. We can print output by -> print(string.format(23))
so, output will be as -> my age is 23 years old
.
I'm quessing is that when we have multiple '{}'
in a string we have to send multiple arguments to '{}'
the arguments are in a list or a tuple like (1, 2,3)
. How can we apply .format()
to this?
I have this doubt while solving this problem -> question: I am 12 years 3 months 8 days old
to required output: I am 3 years 8 months 12 days old
. (Numbers should be in sorted form).