Exercise 35

Write a Python algorithm that take an url as input and return it as clickable link address.

Solution

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# Example of url
url = "https://www.my-courses.net"
# Transforme the url into a link
link = f"<a href="{url}">{url}</a>"
print(link)
# Example of url url = "https://www.my-courses.net" # Transforme the url into a link link = f"<a href="{url}">{url}</a>" print(link)
# Example of url
url = "https://www.my-courses.net"

# Transforme the url into a link
link = f"{url}"

print(link)





Explanation:

  1. The program uses an f-string: to create a variable link containing the HTML string for a hyperlink.
  2. The url variable: is inserted into the string both as the address and the display text for the link.
  3. The output will be: https://www.example.com.

 

Younes Derfoufi
my-courses.net

Leave a Reply