DEV Community

Aditi Sharma
Aditi Sharma

Posted on

Day 2

Hello dev community 👋

This is Day 2 of my Python learning journey. Today I focused on docstrings—something small but very powerful in writing clean and professional code.


🔹 What are Docstrings?

Docstrings are string literals that appear right after the definition of a function, class, or module.

They explain what the code does and act as in-code documentation.

Think of docstrings as a "manual" for your functions.


🔹 Why Use Docstrings?

  • ✅ Improve code readability
  • ✅ Help others (and future you) understand code faster
  • ✅ Work with tools like help() and IDE hints
  • ✅ Make collaboration easier in bigger projects

🖥 Coding Practice


python
def greet(name):
    """Return a friendly greeting message for the given name."""
    return f"Hello, {name}!"

print(greet("World"))
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
suvrajeet profile image
Suvrajeet Banerjee

Docstring day! 📝