Exercise 66

Write a Python program that extract the list of all urls from given a string s. Example if s = "You can use google or facebook" The algorithm returns the list

['' , '']


def extractURL(s):
# initializing the list of urls:
listURL = []

# converting the string s into a list
L = s.split()

for element in L:
if (element.startswith('https://') or element.startswith('http://')):
return listURL

# Teting algorithm
s = "You can use google or facebook"
print(extractURL(s)) # The output is:
# ['', '']

Younes Derfoufi

Leave a Reply