Is it possible to use% r in raw_input in python?
In context, I'm working on Zed Shaw Exercise 12 . (Great resource! The lessons are very useful and well developed.)
I play in extra credit, trying to get raw_input to repeat what I typed. I know I can do the same with a print expression, but I'm curious if I can execute it in raw_input.
The code I am typing is:
from sys import argv script, firstname, lastname = argv age = raw_input("Hello %r, what is your age? ") % firstname print ("Ahh, Mr. %r, you are %r years old.") % (lastname, age)
The error I am getting is:
Traceback (most recent call last): File "ex13a.py", line 5, in <module> age = raw_input("Hello %r, what is your age? ") % firstname TypeError: not all arguments converted during string formatting
Thanks in advance!
source share