Basically I'm looking for concatenating the strings and variable together.
In Java:
String s = "HI my name is "+var_name+" I'm "+age+" years old";
In PHP:
$s = "Hi my name is ".$var_name." I'm ".$age." years old";
I want a similar thing in Python. I know the format function supported by Python 3.0 and above but I have a constraint of running it at Python version 2.6. I can't upgrade so please tell me the best method.
P.S - I came to know that format works in Python 2.6 also. If you have any other method please let me know that also. It's always good to know more.
.format works on Python 2.6 too:
"Hi my name is {name}. I'm {age} years old.".format(name="John", age=30)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With