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 😊7 Antworten
+ 1
If video I'd starts with a digit.. Not show any output..
+ 1
I think it may contain special charecter -, _. So will it covered by your regex..
+ 1
I think that your regex pattern in the elif statement could be
add=re.findall('e/.*#x27;,inp)
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
0
Jayakrishna🇮🇳 thank you, man, now It passed one more test, still one remain🤔
0
Yeah, it turned out that the second [A-Za-z] was unnecessary, thank you one more time
0
Yeah, actually it should be that way😬