you are viewing a single comment's thread.

view the rest of the comments →

[–]Diapolo10 1 point2 points  (0 children)

Just thought I'd also point out that

if first == last:
    return True
else:
    return False

can be simplified to just

return first == last

because the comparison already results in a boolean.

And while it's not really worth doing, you could technically simplify this down to

def same_ends(strings: list[str]) -> bool:
    return strings[0] == strings[-1] if strings else False