Why this o/p?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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
1 Answer
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