Challenge: User Auth
Opgave
Swipe to start coding
Let's improve your User class!
- Create the class attribute
is_authenticatedin theUserclass. - Define the
login()method that takes argumentsselfandtaken_password. - The
login()method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrueshould be assigned to theis_authenticatedattribute.
If the user password is not equal to the taken password, the"Wrong password!"should be written in the console. - Define the
logout()methods. This method should assign theFalsevalue to theis_authenticatedinstance attribute.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 8
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Suggested prompts:
Opsummér dette kapitel
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 2.78
Challenge: User Auth
Stryg for at vise menuen
Opgave
Swipe to start coding
Let's improve your User class!
- Create the class attribute
is_authenticatedin theUserclass. - Define the
login()method that takes argumentsselfandtaken_password. - The
login()method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrueshould be assigned to theis_authenticatedattribute.
If the user password is not equal to the taken password, the"Wrong password!"should be written in the console. - Define the
logout()methods. This method should assign theFalsevalue to theis_authenticatedinstance attribute.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 8
single