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

single

bookChallenge: 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_user that takes parameters username, email, and age.
  • 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, and age, and assign the corresponding values.
  • Add the user dictionary to the users_db list using the appropriate method.
  • If everything is successful, return the message "User {username} registered successfully!", where {username} is the actual username.
  • Call the register_user function with example parameters for a user, either by passing arguments directly or as a dictionary.

解答

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

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

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

セクション 1.  9
single

single

AIに質問する

expand

AIに質問する

ChatGPT

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

some-alt