string_manupulation_in_python

Run Settings
LanguagePython
Language Version
Run Command
print("Hello World!") string1 = "HeLLO Ganesh" string2 = "esh" print("original string : " + string1) print(string1.lower()) print(string1.upper()) if string1.find("esh") == -1 : print("given string not found") else : print("string found at position : ", string1.find("esh")) print("string2 is found : " , string1.find(string2,0,13)) print("length of string is: " ,len(string1)) # let us create a test string testString1 = "Hello World!" print("Original String: "+ testString1) # Now let us try to replace/substitute a substring of this string with another string print("Replacing World with Planet") print(testString1.replace("World","Planet")) # Now let us try to split the string, into separate words # let us split it wherever there is a space print("Splitting the string into words, wherever there is a space") print(testString1.split(" ")) print(testString1.rsplit(" ")) # Remove leading and trailing whitespace characters testString2 = "Hello World! " print("Current Test String=" + testString2) print("Length (there are whitespaces at the end):" , len(testString2)) print("Length after stripping " , len(testString2.strip()))
Editor Settings
Theme
Key bindings
Full width
Lines