Skip to content

Commit

Permalink
mouredev#11 - Python
Browse files Browse the repository at this point in the history
  • Loading branch information
restevean committed May 28, 2024
1 parent e7b03f2 commit 70344ec
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Retos/Reto #11 - URL PARAMS [Fácil]/python/restevean.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Exercise
"""


def get_url_parameters(url):
# Split the URL into the base part and the query string
parts = url.split('?')

# If there are no parameters, return an empty list
if len(parts) < 2:
return []

# Get the query string part
query_string = parts[1]

# Split the query string into key-value pairs
pairs = query_string.split('&')

# Extract the values from the key-value pairs
values = []
for pair in pairs:
key_value = pair.split('=')
if len(key_value) == 2:
values.append(key_value[1])
else:
values.append('')

return values


if __name__ == '__main__':
url = "https://retosdeprogramacion.com?year=2023&challenge=0"
parameters = get_url_parameters(url)
print(parameters)

0 comments on commit 70344ec

Please sign in to comment.