0

Python practice starts with ends with

Hi, I‘m struggling to find the right regex pattern to do the task: starts with m, ends with e, len 4. Following code works but I’m unable to add the ends with part. I tried adding e$ in some variants to the re.match expression with no success. import re word = input() #your code goes here if len(word) == 4 and re.match(r"^m", word): print ("Match") else: print ("No match")

16th Feb 2021, 6:16 PM
Oliver Petters
Oliver Petters - avatar
2 ответов
+ 3
This should work fine => "^m.{2}e
quot;
16th Feb 2021, 6:36 PM
Abhay
Abhay - avatar
+ 1
thank you. it works and the len... isn‘t nessecary anymore too.
16th Feb 2021, 7:30 PM
Oliver Petters
Oliver Petters - avatar