+ 1
Paython Simple Metacharacters 1
Simple Metacharacters Write a program that takes a word as input, and outputs "Match" if the word has 4 letters, starts with "m" and ends with "e". The program should output "No match" if these mentioned requirements aren't satisfied. Sample Input mine Sample Output Match my code : s = input() words = ["mine","mile",] if s in words : print ("Match") else : print ("No match") if s in words : print("No match") and this show my all Test Case right without just one , where is the wrong and thank you
8 odpowiedzi
+ 2
Maybe this helps?
https://youtu.be/qBHLukXP3Ls
+ 5
this is how i did it:
import re
word = input()
#your code goes here
pattern = r"^m..equot;
if re.match(pattern, word):
print("Match")
else:
print("No match")
+ 3
You can do this way too..
https://code.sololearn.com/c7vhVoKk6ExS/?ref=app
+ 2
You need to use a regular expression to make sure your code works for every input matching the conditions.
Take another look at lesson 84.1 of the Python Core course.
+ 1
Hi Raoof!
There are too many words that start from "m" and end with "e" not just mile and mine. It's better to try using regex to solve this challenge since it's related to that lesson.
Alternatively, you can approach this using string slicing method(first and last letters) or there are some in-built functions called startswith() and endswith(). You can use them to check the first letter and last letter.
Syntax:
var = "Raoof"
print(var.startswith("R)) -> True
print(var.endswith("F)) -> False
0
I have look it 2 times but i dont understand yet
0
i have problem to understand
Simple Metacharacters 1
Regular expressions 1
Regular Expressions 3
i would to see if someone help me to skip that here and i can look in arabic to them
- 1
import re
w = input()
p = r"^m..equot;
if re.match(p, w):
print("Match")
else:
print("No Match")