← Back to challenges

Match the Last Item

PythonHardarraysvalidationstrings

Instructions

Create a function that takes a list of items and checks if the last item matches the rest of the list concatenated together.

Examples

match_last_item(["rsq", "6hi", "g", "rsq6hig"]) ➞ True
# The last item is the rest joined.

match_last_item([1, 1, 1, "11"]) ➞ False
# The last item should be "111".

match_last_item([8, "thunder", True, "8thunderTrue"]) ➞ True

Notes

The list is always filled with items.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Number of Times a Character Appears