python string tutorial

Solutions on MaxInterview for python string tutorial by the best coders in the world

showing results for - "python string tutorial"
Oscar
25 Jan 2021
1print("Hello\nworld") #for a new line "\n"
2print("I want to type \"Hello world\" but I can't") #for writing characters used in coding
3
4phrase = "Hello World" #assigning a value
5print(phrase) #for printing values
6
7print(phrase.upper()) #for changing the string to upper case. 
8# If you change "upper" out with "lower" it will changing the string to lower case.
9
10print(len(phrase)) # printing the length of the string
11
12print(phrase[0]) # giving the first letter of the string
13# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
14
15print(phrase.index("e")) # printing where in the string "e" is
16print(phrase.index("llo"))# printing where in the string "llo" is