How to capitalize first letter of every word in a string with Python

2 Answers

0 votes
s = 'python programming language'
  
print(s)
  
s = s.title()
  
print(s)
  
  
  
'''
run:
  
python programming language
Python Programming Language
  
'''

 



answered Apr 13, 2021 by avibootz
0 votes
import string

s = 'python programming language'
  
print(s)
  
s = string.capwords(s)
  
print(s)
  
  
  
'''
run:
  
python programming language
Python Programming Language
  
'''

 



answered Apr 13, 2021 by avibootz
...