Bird
0
0

What is wrong with this session management approach?

medium📝 Debug Q7 of 15
LangChain - Conversational RAG
What is wrong with this session management approach? ```python session_store = {} user_id = 'user101' session_store[user_id] = [] session_store[user_id] = ['Hi'] session_store[user_id].append('How are you?') print(session_store[user_id]) ```
Aprint statement syntax is wrong
BThe initial empty list is overwritten, losing previous data
Cuser_id is not a valid key
Dappend method is used incorrectly
Step-by-Step Solution
Solution:
  1. Step 1: Analyze list assignment and overwrite

    session_store[user_id] is first set to empty list, then immediately overwritten with ['Hi'] losing the empty list.
  2. Step 2: Append to the new list and print

    Appending 'How are you?' works on the new list, so output is ['Hi', 'How are you?'].
  3. Final Answer:

    The initial empty list is overwritten, losing previous data -> Option B
  4. Quick Check:

    Overwriting list loses old data [OK]
Quick Trick: Avoid overwriting session list to keep all messages [OK]
Common Mistakes:
  • Thinking append is incorrect
  • Assuming user_id key is invalid
  • Believing print syntax is wrong

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes