+ 1

[SOLVED] Why code doesn't work?

I am solving "YouTube Links" code coach but I can't solve this problem. https://code.sololearn.com/cxjnY21fYhcZ/?ref=app

26th Mar 2022, 1:30 PM
Yagub!
Yagub! - avatar
5 Respuestas
+ 1
Do you asking about removing errors? If yes, add proper identation.. If you don't know learn about identation.. About logic, They may be many ways, trying yourself finding logic is important.. According to your logic, first find if input contains youtube.com Or youtu.be/ str has method find() which return index of substring otherwise returns -1 so on -1 go to replace 2nd link or replace first link edit: Yagub! alternatively you have count("sub_str") to find how many times sub_str in in. index("sub_str") method which return index of substring, if not found raise error.. you can find just last index of / and find next all charecters and print, type of link don't matters.. hope it helps.. try to implement again...
26th Mar 2022, 2:40 PM
Jayakrishna 🇮🇳
+ 1
It has identation mistakes First you need find which type of the link , then try to replace. See if input is https://www.youtube.com/watch?v=2345789 Then it prints as it is. It don't raise error.. According to your logic no need try catch. Replace just replaces if any found as first argument otherwise its no effect.
26th Mar 2022, 1:35 PM
Jayakrishna 🇮🇳
+ 1
Jayakrishna🇮🇳, so what should I change?
26th Mar 2022, 1:47 PM
Yagub!
Yagub! - avatar
+ 1
Jayakrishna🇮🇳 , thanks bro! I needed function to find if there is such piece of string.
26th Mar 2022, 2:44 PM
Yagub!
Yagub! - avatar
+ 1
You're welcome.. Yagub! Try again and reply if not work.. edit: oh. solved.. great 👍
26th Mar 2022, 2:49 PM
Jayakrishna 🇮🇳