[Python-Help] how does the % work?

bob gailer bgailer at gmail.com
Fri Mar 22 18:31:49 CET 2013


It is better to post to just one list at a time.

On 3/22/2013 1:06 PM, leonardo selmi wrote:
> name = raw_input("What is your name?")
> quest = raw_input("What is your quest?")
> color = raw_input("What is your favorite color?")
>
> print """Ah, so your name is %s, your quest is %s,
> and your favorite color is %s."""  % (name, quest, color)
Runs OK for me!

The traceback does not match the code. Please post the code that 
actually generated this:

   File "/Users/leonardo/print.py", line 5, in <module>
     favourite color is %s.''') % (name, quest, color)
TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'


-- 
Bob Gailer
919-636-4239
Chapel Hill NC




More information about the Python-list mailing list