FAQ: Lambda Function Code Challenge - Double Square

This community-built FAQ covers the “Double Square” exercise from the lesson “Lambda Function Code Challenge”.

Paths and Courses
This exercise can be found in the following Codecademy content:

FAQs on the exercise Double Square

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I don’t undestand the solution provided for this exercice :
here the solution :
double_square = lambda num: 2 * num * num

print double_square(5)
print double_square(3)

results provided are 25 then 9

but with that formula if input is 5 you should compute 2 * 5 * 5 so 50 not 25 ??


Please post a link to the challenge in question.


I am late to the party, may be there it is better they emphasize the wording “The function should return twice the square of” as it easily missed by skimmers like us. May be that could be the intention :roll_eyes: :crazy_face:

So we are now expecting the authors to consider ‘skimmers like us?’ Even skimming gets the message clear unless one skips right over it. There is definitely enough information to work with. How does one make it more explicit without more superfluous verbosity?

Would that be possible to ask lambda to return more than one result?

I tried to add a comma or offer two equations, but nothing works.

If there is, it is not intuitive. With the use of an iterator it is possible to return multiple values in a list after invoking the lambda on an iterable, each in turn.


[*map(lambda x: x[0] * x[1], ((2, 3), (4, 5), (6, 7), (8, 9)))]
[6, 20, 42, 72]

Note that the lambda takes one parameter, and applies the function to that parameter as the iterator cycles through the iterable.

I copy pasted the supplied solution in Jupyter Notebook and it worked fine, then tried this:

double_square = lambda num: 2 * num**2

and it gave the correct answer here, too