DEV Community

Discussion on: Replacing characters in a string using Python

Collapse
 
abdelrahman_dwedar profile image
‘Abdelraḥman Dwedar 👨🏻‍💻🇵🇸

Great blog! 👏🏻

We can also use this trick:

string = "python is a programming language"

print(string.replace(string[0], string[0].upper()))
Enter fullscreen mode Exit fullscreen mode

Which will turn the first character of the string into upper case(capital) :)