🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Regular Expressions: all 10 questions

Quiz: Regular Expressions · Question 9 of 10

What does this print? (code)

What does this print?

import re
words = ["0110", "0101", "1", "10010"]
print([w for w in words if re.fullmatch("0*10*10*", w)])
  1. A.['0110', '0101']
  2. B.['0110', '0101', '10010']
  3. C.['1']
  4. D.['10010']
Answer & explanation

Correct answer: ['0110', '0101', '10010']

01010* means exactly two 1s; 0110, 0101 and 10010 each have two.

Can you get the rest right without peeking?

Take the timed Quiz: Regular Expressions quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →