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:]))
4 Respuestas
+ 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)
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:]))
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
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:]))