← Quiz: Regular Expressions in Python: all 10 questions
Quiz: Regular Expressions in Python · Question 3 of 10
Which function should you use to check that a whole input is a valid PIN code of 6 digits?
Which function should you use to check that a whole input is a valid PIN code of 6 digits?
- A.re.search(r"\d{6}", s)
- B.re.match(r"\d{6}", s)
- C.re.findall(r"\d{6}", s)
- D.re.fullmatch(r"\d{6}", s)
Answer & explanation
Correct answer: re.fullmatch(r"\d{6}", s)
Only fullmatch rejects extra characters before or after the six digits.
Can you get the rest right without peeking?
Take the timed Quiz: Regular Expressions in Python quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →