Quiz Complete, well Done!
String slicing in Python is
, meaning the first character has an index of 0.
The replace() method can also be used to remove specified characters from a string by replacing them with an empty
.
Case Conversion
The
method splits a string into a list of substrings based on a specified delimiter.
Which string method is used to split a string into an array of substrings?
What is the output of the following code?
String str = " Hello ";
System.out.println(str.trim());
The
method removes leading and trailing whitespace from a string.
What will the following code snippet output?
str = "Hello World!";
print(str.substring(6));
Which method is used to check if a string contains a specified sequence of characters?
Which symbol is used to perform string slicing?
Negative indices can be used in string slicing to start counting from the
of the string.
Which of the following statements is true about the 'replace' method?
Which string method is used to convert a string to lowercase?
What will the following code snippet output?
string = 'Hello, world!'
new_string = string.replace('o', 'a', 2)
print(new_string)
Substring
Trimming
What is the function used to find the length of a string?
The
method replaces a specified substring with another substring.
Which method is used to join elements from a list into a single string in Python?
The replace() method returns a
where all occurrences of the specified phrase are replaced with the specified replacement.