Challenge: Positional Arguments
Task
Swipe to start coding
Implement the register_user function to validate a user's age and add them to the database.
- Define the function
register_userwith the parametersusername,email, andage. - Inside the function, check if
ageis less than 18. If so, return the message"Registration failed: age must be 18 or older.". - Create a dictionary named
userwith keys"username","email", and"age". Assign the function parameters (username,email,age) as the values for these keys. - Add the
userdictionary to theusers_dblist. - Return the message
"User {username} registered successfully!"using the actual username. - Call
register_userpassing specific values (arguments) for a test user.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 2
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 4.17
Challenge: Positional Arguments
Swipe to show menu
Task
Swipe to start coding
Implement the register_user function to validate a user's age and add them to the database.
- Define the function
register_userwith the parametersusername,email, andage. - Inside the function, check if
ageis less than 18. If so, return the message"Registration failed: age must be 18 or older.". - Create a dictionary named
userwith keys"username","email", and"age". Assign the function parameters (username,email,age) as the values for these keys. - Add the
userdictionary to theusers_dblist. - Return the message
"User {username} registered successfully!"using the actual username. - Call
register_userpassing specific values (arguments) for a test user.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 2
single