FuzzyString

Python Morsels Exercise

String-like class supporting case-insensitive comparisons

3 bonuses 8 hints 10 solutions 305 users solved 23 reviews

I'd like you to write a FuzzyString class which acts like a string, but does comparisons in a case-insensitive way.

For example:

>>> greeting = FuzzyString('Hey TREY!')
>>> greeting == 'hey Trey!'
True
>>> greeting == 'heyTrey'
False
>>> greeting
'Hey TREY!'

I'd like you to make sure equality and inequality match case-insensitively at first. I'd also like you to ensure that the string representations of your class match Python's string object's default string representations.

For the first bonus, try to ensure the other comparison operators work as expected:

Bonus 1


This is just a preview of the problem statement.

This exercise includes 3 bonuses, 8 hint links, and automated tests.

To solve this exercise, sign in to your Python Morsels account.

A learning habit for experienced Pythonistas

Profile picture of Trey

My name is Trey Hunner and I hold Python trainings for teams. I've spent countless hours refining my most interesting Python exercises into Python Morsels, a Python skill-building platform for folks who already know Python.

Python Morsels is design to help you improve your Python skills every week through 1 hour of deliberate practice.

Let me help you write more beautiful Python code. Sign up for Python Morsels to access this exercise and many more.

Join Python Morsels ✨