Skip to main content
← CoursesPython FoundationsModule 8 · Modern Python and capstoneargparse mini-CLIpredict163 / 170
💬 Discuss🧪 Playground+100 XP
Task
📝 **Question:** Predict the output. The args list has \`--shout\` so \`args.shout\` is True and the greeting is upper-cased. 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.

Keep going

🔮 Predict the output

Read the code carefully

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("name")
parser.add_argument("--shout", action="store_true")
args = parser.parse_args(["Ada", "--shout"])

msg = f"hi {args.name}"
print(msg.upper() if args.shout else msg)

What will the program print? Write here:

📣 Help someone learn PythonShare this lesson with a friend — the first 15 are free, no signup.Tweet

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…