セクション 1. 章 9
single
Challenge: Positional Arguments
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
Implement the register_user function that checks the user's age, adds their details to a database (users_db), and returns a success or failure message.
- Define the function
register_userthat takes parametersusername,email, andage. - Inside the function
register_user, check if age is less than 18. If it is, return the message"Registration failed: age must be 18 or older.". - Create a dictionary user with the keys
username,email, andage, and assign the corresponding values. - Add the user dictionary to the
users_dblist using the appropriate method. - If everything is successful, return the message
"User {username} registered successfully!", where{username}is the actual username. - Call the
register_userfunction with example parameters for a user, either by passing arguments directly or as a dictionary.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 9
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください