[Solved] Why isn't one of my answers being accepted despite being the same as the example solution?

Even though my answer to the first question was accepted with a green mark, my answer to the second question for Modules Python Introduction isn’t being accepted and I’m getting a red mark with a warning for it despite my answer being the same as the one given as a solution. There are three questions in total for this lesson.

My answer:

from datetime import datetime;
current_time = datetime.now();
print(current_time);

The warning:

Did you add a variable current_time below your import statement and set it equal to datetime.now()?

The example solution:

from datetime import datetime

current_time = datetime.now()

print(current_time)

I think it may be due to the semicolons at the end of the lines(?)

2 Likes

Yea it’s an imprecise warning.

I think it’s against some sort of python guideline (check pep 8 below) about spacing between imports and main code. Most jobs require you to know standard uses like these.

@lisalisaj’s mention of the semicolon is also possible, since they probably don’t fit these standards.

3 Likes

Although it didn’t go away when i only deleted the semicolons, when i also added spaces between the lines, it went away.

Got it. The warning went away. Thanks.

1 Like

I seem to remember that being one of the really poorly checked lessons that requires exact text matches and such rather than testing if the statements are being executed or not. Reminds me strongly of the command line lessons. It’s annoying but you just have to live with them for now. Semicolons though, eww :wink:.

2 Likes