セクション 1. 章 11
single
Challenge: Optional Arguments
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
You are working with a simple user management system.
Your goal is to implement a function add_user() that adds new users or updates existing ones in a global list called users_db.
- Define a function
add_user(name, age, role="user", status="active"). - Loop through the list
users_dbto check if a user with the same name already exists. - If the user exists, update their details. Then return the message:
"User {name} updated successfully!"."age"→age."role"→role."status"→status.
- If the user doesn't exist, create a new dictionary named
new_userwith the provided details (name,age,role,status), append it tousers_db, and return:"User {name} added successfully!".
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 11
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください