This exercise might seem a bit uninteresting at first because it involves working with an HTML-like syntax at a low level. The purpose for this exercise isn't to familiarize yourself with HTML, but to get some practice with string manipulation in Python.
I'd like you to write a function that accepts two strings containing opening HTML tags and returns True if they have the same attributes with the same values.
Some examples of basic tag comparisons I'd like you to handle:
>>> tags_equal("<img src=cats.jpg height=40>", "<IMG SRC=cats.jpg height=40>") True >>> tags_equal("<img src=dogs.jpg width=99>", "<img src=dogs.jpg width=20>") False >>> tags_equal("<p>", "<P>") True >>> tags_equal("<b>", "<p>") False
This might sound complex and it sort of is.
To make things a little easier:
But your function must:
I encourage you to try solving this exercise without using the standard library at first. Everything but the last bonus should be relatively do-able without importing any libraries.
If you get your tests to pass, consider doing some of these bonuses. Make sure you don't spend too much time trying to get the second or third bonus done though.
This is just a preview of the problem statement.
This exercise includes 3 bonuses, 10 hint links, and automated tests.