Why this o/p?? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

Why this o/p??

import re pattern = r"^gr.y

quot; if re.match(pattern, "gpey"): print("Match 1") if re.match(pattern,"gray"): print("Match2") ^ matches at the beginning of the line right. .. What exactly does it mean????? It checks only the starting character..... or . If not how many characters does it check in the beginning Please help me with this.I'm stuck herešŸ˜¢šŸ˜¢

18th May 2020, 6:55 AM
Sriya
1 Resposta
0
that happend's because your expression evaluates that the string begins with gp followed by any other character that is not a blank space and ends with y
18th May 2020, 7:27 AM
Emanuel MaliaƱo
Emanuel MaliaƱo - avatar