Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I am a beginner
#1
print ('my name is {}'. format ( 'parv'.title()).capitalize())

I want a result in which both 'm' and 'p' are capital
Reply
#2
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'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#3
I got one more answer to this question:

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


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020