I was trying to write something to capitalize each word in a sentence. And it works fine, as follows:
print " ".join((word.capitalize() for word in raw_input().strip().split(" ")))
If the input is 'hello world', the output would be :
Hello World
But I tried writing it differently as follows :
s = raw_input().strip().split(' ')
for word in s:
word.capitalize()
print ' '.join(s)
And its output would be wrong :
hello world
So what's wrong with that, why the result isn't the same ?! Thank you.