I want to capitalize each word inside the output.
a =('name', 'is', 'james')
b = '**'.join(a)
print (b.capitalize()) #<----- the method work only for the first word...
CodePudding user response:
Method capitalize() only capitalizes the first character of the string b.
If you want to capitalize every word, you would have to do so in the joining process.
For example, you could write it like this:
a = ('name', 'is', 'james')
b = "**".join(n.capitalize() for n in a)
print(b)
CodePudding user response:
You can do it via comprehension:
tuple(word.capitalize() for word in a)