0

fail to pass tests, solving a task about regular expirations.

Here is my code: import re inp = input() if '=' in inp: add = re.findall('=.*

#x27;, inp) output = [string[1:] for string in add] elif 'www.' not in inp: add = re.findall('[A-Za-z]/[A-Za-z].*
#x27;, inp) output = [string[2:] for string in add] print(*output) I am trying to solve the task but suceed to pass only three sololearn tests out of 5. It is just two months how I've been learning Python and I've covered just a bit about regex. Could you please give me a hint why it fails. Thank you in advance 😊

15th Apr 2020, 11:51 AM
Shamil Erkenov
Shamil Erkenov - avatar
7 odpowiedzi
+ 1
If video I'd starts with a digit.. Not show any output..
15th Apr 2020, 12:11 PM
Jayakrishna 🇮🇳
+ 1
I think it may contain special charecter -, _. So will it covered by your regex..
15th Apr 2020, 12:28 PM
Jayakrishna 🇮🇳
+ 1
I think that your regex pattern in the elif statement could be add=re.findall('e/.*
#x27;,inp)
15th Apr 2020, 12:53 PM
John Robotane
John Robotane - avatar
0
Here is the task: You and your friends like to share YouTube links all throughout the day. You want to keep track of all the videos you watch in your own personal notepad, but you find that keeping the entire link is unnecessary. Keep the video ID (the combination of letters and numbers at the end of the link) in your notepad to slim down the URL. Task: Create a program that parses through a link, extracts and outputs the YouTube video ID. Input Format: A string containing the URL to a YouTube video. The format of the string can be in "https://www.youtube.com/watch?v=kbxkq_w51PM" or the shortened "https://youtu.be/KMBBjzp5hdc" format. Output Format: A string containing the extracted YouTube video id. Sample Input: https://www.youtube.com/watch?v=RRW2aUSw5vU Sample Output: RWW2aUSwvU
15th Apr 2020, 11:52 AM
Shamil Erkenov
Shamil Erkenov - avatar
0
Jayakrishna🇮🇳 thank you, man, now It passed one more test, still one remain🤔
15th Apr 2020, 12:20 PM
Shamil Erkenov
Shamil Erkenov - avatar
0
Yeah, it turned out that the second [A-Za-z] was unnecessary, thank you one more time
15th Apr 2020, 12:40 PM
Shamil Erkenov
Shamil Erkenov - avatar
0
Yeah, actually it should be that way😬
15th Apr 2020, 1:12 PM
Shamil Erkenov
Shamil Erkenov - avatar