0

Why it doesn't remove the pattern?

Wast trying to solve the youtube task but everything except the first input worked and I don't know why https://code.sololearn.com/cks35Ok8dIUR/?ref=app

11th May 2020, 7:58 PM
César Vázquez Valencia
César Vázquez Valencia - avatar
7 Respostas
+ 1
No problem.
11th May 2020, 8:27 PM
Russ
Russ - avatar
0
"https://www.youtube.com/watch?v=kbxkq_w51PM".split() doesn't do anything to the string (apart from put it in a list). So pattern will never be in link.split(). I guess all the other cases follow the alternative format..? Edit to explain: print("hello" in "hello world!") # True print("hello" in ["hello world!"] # False since "hello" is not an element of the list
11th May 2020, 8:17 PM
Russ
Russ - avatar
0
But the .remove(). ?
11th May 2020, 8:19 PM
César Vázquez Valencia
César Vázquez Valencia - avatar
0
The remove() isn't executed because the if returns False.
11th May 2020, 8:20 PM
Russ
Russ - avatar
0
That makes sense. Thank you very much!
11th May 2020, 8:21 PM
César Vázquez Valencia
César Vázquez Valencia - avatar
0
Even if it were executed, it would only cause an error since "watch?=" is not an element in ["https://www.youtube.com/watch?v=kbxkq_w51PM"].
11th May 2020, 8:22 PM
Russ
Russ - avatar
0
👌👍Thanks again
11th May 2020, 8:25 PM
César Vázquez Valencia
César Vázquez Valencia - avatar