Capitalise every other letter in a string in Python? -
i've been trying define function capitalise every other letter , take spaces accout example:
print function_name("hello world")
should print "hello world" rather "hello world"
i hope makes sense. appreciated.
thanks, oli
def foo(s): ret = "" = true # capitalize char in s: if i: ret += char.upper() else: ret += char.lower() if char != ' ': = not return ret >>> print foo("hello world") hello world'
Comments
Post a Comment