[Python] how do fix my python code that uses decorators? my function is just a really basic...

Discussão em 'Python' iniciado por Stack, Fevereiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    I was making this code to teach other fellow beginner programmers but it seems to produce a NameError: name 'decorator' is not defined The code is supposed to return "You have added sprinkles" "Here is your ice-cream"

    My Code:

    def sprinkles(func):
    def wrapper():
    return "you have added sprinkles"
    func()
    @decorator
    def ice_cream():
    return "here's your ice-cream"
    print(ice_cream())

    Continue reading...

Compartilhe esta Página