Python practice starts with ends with | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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