Gribouillis has allready posted code similar to this in his snippets, but here version for input suitable for for expressions, generators and list comprehensions. Need to add robustness by some try...except blocks for real world use.
Input generator
# make this code to work in both Python 2 and 3 template
from __future__ import print_function, division
try:
input, range = raw_input, xrange
except:
pass
def input_generator(prompt='> ', stop=''):
'''
keep asking for input until stop value entered
'''
while True:
inp = input(prompt)
if inp.lower() == stop.lower():
return
yield inp
print('Give words for me to capitalize, end by "quit".')
print(' '.join(inp.strip().capitalize() for inp in input_generator('word> ', 'quit')))
ZZucker 342 Practically a Master Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
Ene Uran 638 Posting Virtuoso
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
vegaseat commented: learned something new +14
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.