Bird
0
0

When parsing the string 'apple, , banana, , cherry' using CommaSeparatedListOutputParser, what is the resulting list?

hard📝 Application Q8 of 15
LangChain - Output Parsers
When parsing the string 'apple, , banana, , cherry' using CommaSeparatedListOutputParser, what is the resulting list?
A['apple', null, 'banana', null, 'cherry']
B['apple', '', 'banana', '', 'cherry']
C['apple', ' ', 'banana', ' ', 'cherry']
D['apple', 'banana', 'cherry']
Step-by-Step Solution
Solution:
  1. Step 1: Understand the parser behavior

    The CommaSeparatedListOutputParser splits the input string by commas.
  2. Step 2: Handling empty or whitespace-only items

    It trims whitespace and removes empty strings from the resulting list.
  3. Final Answer:

    ['apple', 'banana', 'cherry'] -> Option D
  4. Quick Check:

    Empty entries are discarded [OK]
Quick Trick: Empty or whitespace-only items are removed [OK]
Common Mistakes:
  • Assuming empty strings remain in the list
  • Not trimming whitespace before filtering
  • Expecting null values for empty items

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes