Python Beginner here. Would like to ask you a very simple question.
This is the first sample code :-
print "I will \"Add\" any two number that you type."
x = raw_input("What is the first number?")
y = raw_input("What is the second number?")
z = x + y
print "So, %d plus %d equals to %d" % (x, y, z)
Using %d in the last line gives me the error :
TypeError: %d format: a number is required, not str
This is the second sample code :-
print "I will \"Add\" any two number that you type."
x = raw_input("What is the first number?")
y = raw_input("What is the second number?")
z = x + y
print "So, %r plus %r equals to %r" % (x, y, z)
This does not give the error that the first code gave.
So my question is why using %d gives me the error but using %r does not give me the error ?