Not all errors throw red lines. This one-line function hides a classic beginner mistake. Can you crack the code? What’s wrong with this function? A) The docstring isn’t placed correctly B) The return value should be f-string for clarity C) Missing return type annotation D) All of the above Reply with your answer! Learn how clean code helps build better prompts on Infosys Springboard. #CodeCrack #promptengineer #BeginnerCoding #LearnToCode #InfosysSpringboard
A.The docstring isn't placed correctly def greet(name): " " "This function greets the user." " " return " Hello " + name This is Right Code...
Option B Infosys Springboard #CodeCrack #promtengineer #BeginnerCodinh #LearnToCode #InfosysSpringboard
Classic silent bug. The string "Create a prompt based on the topic" isn’t actually working as a docstring — because it’s not using triple quotes ("""). No red lines, no warnings… just a missing docstring silently lurking 👀
A) The docstring isn’t placed correctly def make_prompt(topic): """Create a prompt based on the topic""" return "Explain " + topic + ". What is it and how does it work?"
The correct answer is: A) The docstring isn’t placed correctly Why? In Python, a docstring should be immediately after the def line, indented inside the function.
Option C
Option A
should comes with three double quates for docstring and formating string with curly braces
A) The docstring isn’t placed correctly
AI intern @ infosys springboard 6.0 || CSBS Final Year || Python || SQL || Machine Learning || Deep Learning || AWS Cloud || HTML/CSS/JS || Git & GitHub || ⭐100+ Leetcode ||
3modef make_prompt(topic: str) -> str: """Create a prompt based on the topic.""" return f"Explain {topic}. What is it and how does it work?" This is the correct form of code Option D All the above