Зміст курсу
In-Depth Python OOP
In-Depth Python OOP
Challenge: User Auth
Swipe to show code editor
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
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 theFalse
value to theis_authenticated
instance attribute.
Дякуємо за ваш відгук!
Challenge: User Auth
Swipe to show code editor
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
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 theFalse
value to theis_authenticated
instance attribute.
Дякуємо за ваш відгук!