String methods in python

Ace your homework & exams now with Quizwiz!

s.replace(Oldsub, Newsub)

replaces all occurrences of Oldsub with Newsub

s.join(list)

Concatenate list into a string using s as a separator

s.center(width)

Copy of s centered in a field of given width

s.lower()

Copy of s in all lowercase letters

s.upper()

Copy of s with all characters converted to Uppercase

s.lstrip()

Copy of s with all leading white space removed

s.title()

Copy of s with each character of each word capitalized

s.capitalize()

Copy of s with only the first character capitalized

s.rjust(width)

Copy of s with trailing white space removed

s.count(sub)

Count the number of times where sub occurs in s

s.find(sub)

Finds the 1st position where sub occurs in in s

s.ljust(width)

Like center but left justified

s.rfind(sub)

Like find, but returns the rightmost position

s.split()

Split s into substrings


Related study sets

CH59: Assessment and management of PT w/ Male Reprod d/o

View Set

kins 4100: chapter 12 linear forces part 2

View Set