← 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)])
- A.['0110', '0101']
- B.['0110', '0101', '10010']
- C.['1']
- 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 →