Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Optional Arguments | Section
/
Python Functions
セクション 1.  11
single

single

bookChallenge: 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_db to 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_user with the provided details (name, age, role, status), append it to users_db, and return: "User {name} added successfully!".

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  11
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt