This is pretty basic:
my_name="nishant"
my_age=24
print "My name is %s"%my_name
print "My age is %d & my name is %s, what are you ?" %(my_age, my_name)
It works fine and prints the intended result, but if I replace the last line as this:
print "My age is %d & my name is %s, what are you ?" %my_age , %my_name
I get this error:
File "my_tests.py", line 7
print "My age is %d & my name is %s, what are you ?" %my_age, %my_name
^
SyntaxError: invalid syntax
My question is :
- Why is
%(my_age, my_name)!=%my_age , %my_name? - How does Python interpret something like this?