I'm solving the following challenge, and the code I wrote is correct (I know that after comparing my code with discussions), however the testcases fail. please have a look to the problem and confirm my code is good.
regex_integer_in_range = r"^[1-9][0-9]{5}$"
regex_alternating_repetitive_digit_pair = r"(\d)(?=\d\1)"
import re
P = input()
print (bool(re.match(regex_integer_in_range, P))
and len(re.findall(regex_alternating_repetitive_digit_pair, P)) < 2)
When running the program, some odd error says:
Traceback (most recent call last):
File "Solution.py", line 53, in <module>
request = json.load(open(run_directory + "request.json"))
IOError: [Errno 2] No such file or directory: 'request.json'
please try running the same
regex_integer_in_range = r"^[1-9][0-9]{5}$" # Do not delete 'r'.
regex_alternating_repetitive_digit_pair = r"(\d)(?=\d\1)" # Do not delete 'r'.
import re
P = input()
print (bool(re.match(regex_integer_in_range, P))
and len(re.findall(regex_alternating_repetitive_digit_pair, P)) < 2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.