Skip to content

Instantly share code, notes, and snippets.

@dheerajdlalwani
Last active February 28, 2024 13:47
Show Gist options
  • Save dheerajdlalwani/51990016a5697b24c39638e225385eb1 to your computer and use it in GitHub Desktop.
Save dheerajdlalwani/51990016a5697b24c39638e225385eb1 to your computer and use it in GitHub Desktop.

Anchor that URL

This challenge needs to be solved in Python.

problem

  • You are given an .txt file.
  • You are supposed to write a python program to get all the URLs from the file and convert them into anchor tags.

For example,

https://example.com

will be replaced by

<a rel="noreferrer noopener" target="_blank" title="https://example.com" href="https://example.com" >https://example.com </a>

gotchas

  • rest of the content must be left EXACTLY as it was in the input file
  • they should have the rel, target, href and title properties as shown in the above example.
  • your solution should be a .py file with a function anchor_that_url(input) which takes the path of a .txt file.
  • the function should create an output.txt file which has the output.
  • test your code for various different inputs.
  • do proper error handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment