What's wrong with this one-line function?

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

  • No alternative text description for this image
Balaguru K

AI intern @ infosys springboard 6.0 || CSBS Final Year || Python || SQL || Machine Learning || Deep Learning || AWS Cloud || HTML/CSS/JS || Git & GitHub || ⭐100+ Leetcode ||

3mo

def 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

Viren Mori

Student at Maharaja Krishnakumarsinhji Bhavnagar University (MKBU)

3mo

A.The docstring isn't placed correctly def greet(name): " " "This function greets the user." " " return " Hello " + name This is Right Code...

Jinukala Akhila

Final year student at Sri indu institute of engineering and technology with cpga 8.2 .

3mo

Option B Infosys Springboard #CodeCrack #promtengineer #BeginnerCodinh #LearnToCode #InfosysSpringboard

Tiyasha Giri

17y/o| AI | Health care| NEET 2027 Aspirant | Psychology + Healthcare AI + Buisness strategy|

3mo

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 👀

Himanshu Choudhary

Code. Build. Learn. | Web Dev | Java & Python | DSA | Diploma CSE | Future Software Engineer

3mo

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?"

Harsh Tyagi

Immediate Joiner | Frontend Developer with expertise in Full Stack Development

2mo

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.

Like
Reply
patil saisupraja

Btech@SRET | Aspiring Cloud Engineer |Java developer intern | Passionate about Innovation | Eager to Learn and Contribute

3mo

Option C

Like
Reply
Priya Chouhan

Looking for job django, machine learning

3mo

Option A

Like
Reply
Jaya Prasad P

Certified from Stanford University CIP’25 | Intern at Infosys (Springboard) | AWS re/Start Program Graduate | Cloud Engineer Enthisiast

3mo

should comes with three double quates for docstring and formating string with curly braces

Like
Reply
Aaradhna Gurjar

Intern @infosysSpringboard | CSE’25 | JAVA | JavaScript | SQL | HTML | CSS | Pragati : Path to Future Cohort 6

3mo

A) The docstring isn’t placed correctly

Like
Reply
See more comments

To view or add a comment, sign in

Explore content categories