Exam PCAP All QuestionsBrowse all questions from this exam
Question 54

If you want to transform a string into a list of words, what invocation would you use? (Choose two.)

Expected output:

Code:

    Correct Answer: A, C

    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.

Discussion
ziadzidaneOptions: AC

A and C: don't forget a space here : s.split(' ') to avoid the error!

SuvabrataOptions: AC

Correct answer is A. s.split(' ') will give ValueError: empty separator

CC_DC

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.

neked

This is due to copying the OCR results of screenshots in batch without looking

Premi9Options: AC

a is correct C works only if we have space in between quotes s.split(' ') since there is space C is also correct

ciccio_benzina

only A is right. Error with C

macxszOptions: AC

A. s.split () C. s.split (' ')