String handling and the percent operator
Tom Plunket
gamedev at fancy.org
Thu Jul 13 19:30:03 EDT 2006
Simon Forman wrote:
> strings have a count() method.
thanks!
For enrichment purposes, is there a way to do this sort of thing with
a generator? E.g. something like:
def SentenceGenerator():
words = ['I', 'have', 'been', 'to', 'the', 'fair']
for w in words:
yield w
message = "%s %s %s %s"
print message % SentenceGenerator()
(I ask because the above doesn't work)?
-tom!
More information about the Python-list
mailing list