Intermediate
Write a module and import it
Use Path("greeter.py").write_text(...) to create a file greeter.py. The file must define a function greet(name) that returns "Hello, ", then the name, then "!". For example, greet("Asha") returns Hello, Asha!.
Call importlib.invalidate_caches(), then import greeter and print greeter.greet("Asha").
What Check tests
- The module
greeterwas imported greeter.greet("Asha")returnsHello, Asha!greeter.greet("Ravi")returnsHello, Ravi!- An empty name still works
- The module has the name
greeter - The program prints
Hello, Asha!
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.