Skip to content Skip to sidebar Skip to footer

How Do You Capitalize The First Two Letters

I have usernames that are in this format RSmith. I can put them in all upercase or Title them to look like this, Rsmith, but I need RSmith. current script: import csv app_csv =

Solution 1:

You can use basic string slicing:

s = 'rsmith'
s = s[:2].upper() + s[2:]
print(s)

Output:

RSmith

Post a Comment for "How Do You Capitalize The First Two Letters"