0

Youtube link finder problem

I DONT KNOW WHAT IS WRONG IN MY CODE, CAN HELP ME? THIS IS MY CODE; takeLink =list(input()) stri="".join(takeLink ) backSlash=0 if re.search("com",stri): for i in range(len(takeLink)): if takeLink[i]==r'=': break print("".join(takeLink[i+1:])) else: for i in range(len(takeLink if takeLink[i]==r'/': backSlash +=1 if backSlash == 3: break print ("".join(takeLink[i+1:]))

25th Apr 2020, 1:55 PM
G4M3S4L1F3
G4M3S4L1F3 - avatar
4 Answers
+ 1
#The simplest answer😁 link =input('') if '=' in link : lf1 = link.split('=') d = lf1[-1] print(d) else: lf2= link.split('/') m = lf2[-1] print(m)
24th Sep 2020, 3:42 AM
Jahir Raihan Joy
Jahir Raihan Joy - avatar
0
Your code was pulling a syntax error because "for i in range(len(takeLink" is missing ")):" to end it takeLink =list(input()) stri="".join(takeLink ) backSlash=0 if re.search("com",stri): for i in range(len(takeLink)): if takeLink[i]==r'=': break print("".join(takeLink[i+1:])) else: for i in range(len(takeLink)): if takeLink[i]==r'/': backSlash +=1 if backSlash == 3: break print ("".join(takeLink[i+1:]))
25th Apr 2020, 4:57 PM
MyNameIsMutable
MyNameIsMutable - avatar
0
like this? takeLink =list(input()) stri="".join(takeLink ) backSlash=0 if re.search("com",stri): for i in range(len(takeLink)): if takeLink[i]==r'=': break print("".join(takeLink[i+1:])) else: for i in range(len(takeLink)): if takeLink[i]==r'/': backSlash +=1 if backSlash == 3: break print ("".join(takeLink[i+1:])) if so, it did not work
26th Apr 2020, 11:26 AM
G4M3S4L1F3
G4M3S4L1F3 - avatar
0
Need to import re to use re.search also, my bad. This time I tested it directly in code coach and it works great. import re takeLink =list(input()) stri="".join(takeLink ) backSlash=0 if re.search("com",stri): for i in range(len(takeLink)): if takeLink[i]==r'=': break print("".join(takeLink[i+1:])) else: for i in range(len(takeLink)): if takeLink[i]==r'/': backSlash +=1 if backSlash == 3: break print ("".join(takeLink[i+1:]))
26th Apr 2020, 3:28 PM
MyNameIsMutable
MyNameIsMutable - avatar