YouTube Link Finder(solved) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

YouTube Link Finder(solved)

https://code.sololearn.com/cq0Bq4l7U4Vv/?ref=app This is my python solution for the code coach YouTube Link Finder Question My code can't pass the test case 4 Can someone help me

8th May 2020, 3:28 AM
Chase Chai
Chase Chai - avatar
4 Answers
+ 2
This is my solution.I might be a little complicated because I am terrible at coding. After a bit of thinking, I chose to use ruby as the language that I'll use. url = gets.to_s #define the url variable into the video link(string) urlarray = url.chars #define the urlarray into the splited video link array urlarray.reverse! #reverse it to let the first 11 text become the video id videoidarray = urlarray[0..10] #define the videoidarray into the video id array(reversed) videoidarray.reverse! #reverse back the video id videoid = videoidarray.join() #define videoid into the video id(string) puts videoid #output the video id With out description: url = gets.to_s urlarray = url.chars urlarray.reverse! videoidarray = urlarray[0..10] videoidarray.reverse! videoid = videoidarray.join() puts videoid The easier way: url = gets.to_s urlarray = url.chars videoidarray = urlarray[-11..-1] videoid = videoidarray.join() puts videoid Python solution: url = input() def Convert(string): list1=[] list1[:0]=string return list1 urllist = Convert(url) videoidlist = urllist[-11:] print (''.join(videoidlist)) wait, my code is shorter then other ones?
11th Dec 2021, 2:58 PM
lapotist
lapotist - avatar
0
Wow! you made it look so clean Thanks for helping
8th May 2020, 4:03 AM
Chase Chai
Chase Chai - avatar
0
I used the list approach in mind, converted the link(str) to list link = str(input()) youtube = list(link) if len(youtube) > 28: slice1 = youtube[32:] newsluce = ''.join(slice1) print(str(newsluce)) else: slice2 = youtube[17:] output = ''.join(slice2) print(str(output))
26th Jun 2020, 5:27 PM
Onyedikachi Onu
Onyedikachi Onu - avatar
0
Hello
15th Jun 2022, 1:29 PM
lapotist
lapotist - avatar