← Quiz: Python Interview Programs: all 13 questions
Quiz: Python Interview Programs · Question 11 of 13
What does this print? (code)
What does this print?
text = "swiss"
counts = {}
for ch in text:
counts[ch] = counts.get(ch, 0) + 1
print(next(ch for ch in text if counts[ch] == 1))
- A.s
- B.w
- C.i
- D.ws
Answer & explanation
Correct answer: w
s appears 3 times; w is the first character that appears exactly once.
Can you get the rest right without peeking?
Take the timed Quiz: Python Interview Programs quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →