0

Python Core-Regular Expressions_Checking if input word's first 2 letters are "gl"....Help!

This is the code I type in...I am aware it just looks for "gl" in the input word....but if in this line if re.match(pattern,word): I type in (word[0]+word[1]) instead of word, it doesnt work either....Any one can please help me? import re #your code goes here pattern=r"gl" word =input() if re.match(pattern,word): print("Match") else: print("No Match")

25th Feb 2022, 12:12 PM
Cathyboum
2 Respuestas
+ 5
import re #your code goes here pattern=r"^gl.*" word =input() if re.match(pattern,word): print("Match") else: print("No Match")
25th Feb 2022, 12:42 PM
Oma Falk
Oma Falk - avatar
+ 1
thank you Oma
26th Feb 2022, 12:36 AM
Cathyboum