Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41692

Re: how does the % work?

From John Gordon <gordon@panix.com>
Newsgroups comp.lang.python
Subject Re: how does the % work?
Date 2013-03-22 17:14 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <kii3i2$e9n$1@reader2.panix.com> (permalink)
References <mailman.3612.1363971987.2939.python-list@python.org>

Show all headers | View raw


In <mailman.3612.1363971987.2939.python-list@python.org> leonardo selmi <l.selmi@icloud.com> writes:

> hi guys

> i wrote this example :

> 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)

> but i get this error:  Traceback (most recent call last):
>   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'

> how can i solve it?

Are you sure you've given us the exact code?  The printed text doesn't
exactly match.  ("favorite" vs. "favourite", three double-quotes vs
three single-quotes, etc.)

The error message also says that the print statement has a
close-parenthesis after the string and before the arguments, which may be
real problem.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

how does the % work? leonardo selmi <l.selmi@icloud.com> - 2013-03-22 18:06 +0100
  Re: how does the % work? John Gordon <gordon@panix.com> - 2013-03-22 17:14 +0000
  Re: how does the % work? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-22 11:06 -0700
  Re: how does the % work? Tim Roberts <timr@probo.com> - 2013-03-22 21:29 -0700
    Re: how does the % work? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-23 00:04 -0700
    Re: how does the % work? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-23 07:38 +0000
      Re: how does the % work? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-23 00:57 -0700
      Re: how does the % work? Michael Torrie <torriem@gmail.com> - 2013-03-23 09:57 -0600
        Re: how does the % work? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-23 23:53 +0000
      Re: how does the % work? leonardo <tampucciolina@libero.it> - 2013-03-23 18:05 +0100
        Re: how does the % work? Tim Roberts <timr@probo.com> - 2013-03-24 16:35 -0700

csiph-web