Regular Expressions (RegEx) are a powerful tool used to match or search for a pattern in a string. To use them in Python you need to import the re module. You can do this by adding the following line at the top of your file:
import re
Write a regular expression that will match the files with the extension .py or .pyw. You must use the RegEx line anchor $, which matches the end of a string.
pattern = "yourregularexpressionhere"
bool(re.search(pattern, "/users/file.py")) ➞ True
bool(re.search(pattern, "/users/file.pyw")) ➞ True
bool(re.search(pattern, "/users/python/file.txt")) ➞ False
import re from the code.