Lambda Function

in https://www.codecademy.com/paths/data-science/tracks/data-processing-pandas/modules/dspath-intro-pandas/lessons/pandas-ii/exercises/review-ii the lambda function is being used with a backslash but it was not used in previous exercises and the function is not working without a backslash. Why?

1 Like

For quieries about particular sections of code, please try to provide at the very least the line which is causing you trouble. You can do so using the backquote/accent grave character `, e.g.

` ` `
x = 3
` ` `
Would provide the following formatted code.

x = 3

Based on what I think your issue is… In Python the blackslash character \ is used to split a line of code, effectively making a newline but without breaking the statement. The following example shows how the line break is performed (albeit in a very ugly fashion of course).

x = \
3

If you edited the code to remove the backlash but left the statement in two separate parts the code is proably going to throw an error or, potentially an even worse scenario, run but with unexpected bugs.

2 Likes

Thanks man, sorry for the inconvenience I will make sure of that next time

Haha nae worries. Apologies if that came off a little harsh, it wasn’t my intention but text doesn’t really carry tone all that well.

2 Likes

nah man that’s cool, actually it was my first time posting :sweat_smile: