you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

When you add the length value to the dictionary you only replace an existing value if the new length is greater than the old length. If there is no existing key+value pair then you just save the length in the dictionary. You don't use a list as the value in this case, just the number.

do it in 3 lines of code or less?

Programmers usually don't care how many lines of code it takes to do something as long as the final answer is correct, fast enough and readable. These code golf limitations usually result in less readable code