0

(YOUTUBE LINK FINDER PROGRAM) How to increment to the next value of character in I

Here I am aware of the fact that I represents the character that's held in yt_link variable so when I run the if statement until the I value turns to "." then I want to go to the next character that's supposed to be beside "."Which might be "b" if its true then go to next character which could be "e" if true then next so if all the conditions are true then I want split the link by split(".be") and get the youtube ID and print it out How exactly would i be able to do that guys https://code.sololearn.com/cXnKI5C2xGm8/?ref=app

11th Nov 2021, 12:07 PM
A Mohammed Alhaan
A Mohammed Alhaan - avatar
6 Antworten
+ 3
Look at this and you'll get the idea ... yt_links = ( "https://www.youtube.com/watch?v=kbxkq_w51PM", "https://youtu.be/KMBBjzp5hdc" ) for link in yt_links: if "watch?v=" in link: # link contains 'watch?v=' # add 8 to the slicing index (length of 'watch?v=') pure_link = link[ link.index( "watch?v=" ) + 8 : ] elif "youtu.be/" in link: # link contains 'youtu.be' # add 9 to slicing index (length of 'youtu.be/') pure_link = link[ link.index( "youtu.be/" ) + 9 : ] print( pure_link ) # Reference: # https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/ref_string_index.asp
11th Nov 2021, 1:00 PM
Ipang
+ 4
u = input() try: print(u.split("=")[1]) except: print(u.split("/")[-1]) # Keep learning & happy coding :D https://www.sololearn.com/Codes?ordering=MostRecent&query=YouTube%20Link%20Finder
11th Nov 2021, 1:14 PM
SoloProg
SoloProg - avatar
+ 2
Torg start from standard Python standard library and documentation with examples. Also there are plenty video tutorials on YouTube, just make sure you watch Python 3.x version
13th Nov 2021, 7:00 PM
Ilyas Bakirov
Ilyas Bakirov - avatar
+ 1
Torg Just simple hint for you do solve it with less code: look at str.startswith() 😉
11th Nov 2021, 5:12 PM
Ilyas Bakirov
Ilyas Bakirov - avatar
+ 1
Time To Code could you redirect me to some other programs or anything that gives a brief idea about regex, tried studying it seems confusing ngl
13th Nov 2021, 6:33 PM
A Mohammed Alhaan
A Mohammed Alhaan - avatar
+ 1
Ilyas Bakirov thanks bro but have you got any programs or links that teaches it well
13th Nov 2021, 6:33 PM
A Mohammed Alhaan
A Mohammed Alhaan - avatar