Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Find the Bug

00:00 But wait, we need to talk about something. After recording the former lesson, I spotted that there was something not entirely correct in my code. The code still worked, but down the line this could create a bug.

00:14 So here is a bonus challenge for you. Can you spot the bug in this code? You can pause this lesson, and I will show you the bug in a moment.

00:26 And if you need a tip, have a look at the area() function. So maybe this helps you spotting the bug.

00:33 Have you found it? My bug that I introduced was that I am calling the area() function in the f-string with width and then length as the second argument.

00:45 However, in the function definition, length is the first argument, and width is the second one. So this doesn’t matter because we are multiplying both.

00:56 So the solution is still correct, but it’s not entirely correct. So in this case I didn’t see it because it had the same number in the end. But if you have a bigger problem, stuff like this can be a nasty bug.

01:12 So I wanted to point this out, and I hope you didn’t run into this bug when you solved this challenge.

01:19 And again, I only spotted this after recording, so in the next lesson, you will still see the code where the position of width and length is wrong in the area() function call.

01:31 Although this is a bit annoying, it’s a good teaching moment, so you can see that solving challenges sometimes gives the right solution, but in the code, something is not entirely correct.

01:41 So that’s why I decided to keep this in this course and not edit the content from the last lessons out. All right, and with this being said, let’s go on.

Become a Member to join the conversation.