Python Forum

Full Version: I am a beginner
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
print ('my name is {}'. format ( 'parv'.title()).capitalize())

I want a result in which both 'm' and 'p' are capital
You should move both parts into format:

>>> '{} {}'.format('my name'.capitalize(), 'parv'.title()) 'My name Parv'
It's easier with using f-strings (3.6 and newer):

>>> f"{'my name'.capitalize()} {'parv'.title()}" 'My name Parv'
I got one more answer to this question:

print ('my name is {}'.capitalize().format ( 'parv'.title()))