If you want to transform a string into a list of words, what invocation would you use? (Choose two.)
Expected output:
Code:
If you want to transform a string into a list of words, what invocation would you use? (Choose two.)
Expected output:
Code:
To transform the string 'The Catcher in the Rye' into a list of words, using s.split() will break the string at all whitespace, resulting in a list of words as desired. Similarly, using s.split(' ') will split the string at each space, which also results in the desired list of words. Therefore, both s.split() and s.split(' ') are correct invocations for achieving the expected output.
A and C: don't forget a space here : s.split(' ') to avoid the error!
Correct answer is A. s.split(' ') will give ValueError: empty separator
This code is so jacked up wrong. The uppercase S should be a lowercase s, the number 1 should l (letter 'l') and the F in For should be lowercase. Without these changes, the code will not even compile.
This is due to copying the OCR results of screenshots in batch without looking
a is correct C works only if we have space in between quotes s.split(' ') since there is space C is also correct
only A is right. Error with C
A. s.split () C. s.split (' ')