Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with my code
#3
(Sep-06-2023, 07:24 PM)deanhystad Wrote: Make sure you are doing the assignment.

Assignment instruction:
For every incorrect password length, the program will record an entry in a password log file that will include the date/time (updated to the nearest microsecond)

From your post:
I can't work out how to get the output like this; 2023-09-07, password < 6

That date/time string does not have any time. Certainly not any time to the nearest microsecond.

I would start with a program like this:
from datetime import datetime

print(datetime.today())
Output:
2023-09-06 12:31:50.190394
That date/time string has time, and it is updated to the nearest microsecond.

Now try printing the date/time string and a message.
from datetime import datetime

print(datetime.today() "is the current time.")
Output:
2023-09-06 12:46:29.283713 is the current time.
That certainly was easy. I wonder if there is a way to print to a file? That might be worth looking into. Printing automatically appends a newline ("\n") and it has formatting. Looks like a better choice than write().

Quote:The log file has only kept 4 incorrect password attempts
Your program only writes 1 line to the password file. Should it process multiple passwords? To do that you would need a loop that got a password, checked the password, logged the entry.

Your program only writes to the log file if the password is too short or too long. If the password is weak you only print the message to standard output (the console). You are not writing to the log file.

Hi, I have edited my OP.
Reply


Messages In This Thread
Help with my code - by bp12 - Sep-06-2023, 03:09 PM
RE: Help with my code - by deanhystad - Sep-06-2023, 07:24 PM
RE: Help with my code - by bp12 - Sep-07-2023, 10:24 AM
RE: Help with my code - by Pedroski55 - Sep-10-2023, 11:41 AM
RE: Help with my code - by deanhystad - Sep-10-2023, 01:33 PM
RE: Help with my code - by Pedroski55 - Sep-11-2023, 05:15 AM
RE: Help with my code - by deanhystad - Sep-11-2023, 02:49 PM
RE: Help with my code - by bp12 - Sep-17-2023, 02:28 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020