Can somebody please explain why the following code doesn’t work for the purify function exercise? I am getting the error: "your function fails on [4,5,5,4].
new_list = lst
for i in lst:
if i % 2 != 0:
Hello, @adyarao7767713627. Please review the following regarding how to include your code in a post.
Code that is posted without the indentations preserved, is not Python. Indentations are not optional in Python, but are rather an essential part of the language , lacking which your code will not run at all.
Unindented code is difficult to read, requires guesswork concerning your intent, and cannot be copied and pasted for testing, both because it is unindented and because it often contains characters such as left-and right double-quotes that are unreadable to the Python interpreter.
The Codecademy forum provides a quick and easy way to post properly-formatted code. All you need to do is look for the </> icon in the menu bar which appears at the top of the text box while you type.
Press Enter to go to a blank line, click that icon, and you will see this:
Just copy and paste your code directly from the editor into that highlighted portion, and all of the nicely-readable Python formatting will be preserved! Moreover, it will be in a format that can be directly copied and pasted into a Python IDE for testing.
The same icon can be used for highlighting small code snippets in-line for clarity.