When you're struggling with solving a programming exercise, it helps to take a structured approach.
First determine what to do. You can do this by writing down in plain English what you want your program to do. This description is called pseudocode. Write the description as comments in your code by starting each line with a # symbol.
Once you've got a set of steps written down as pseudocode, write the actual code underneath each comment, one at a time.
lengths in variables. Add the lengths together and return the result.
And we're done! You can use this approach for nearly every exercise on this site.