New in python need little help calling a function from another function

def is_all_berries(fruits):
    """Return True if all items in fruits are valid berries."""

    for fruit in fruits:
        if not is_berry(fruit):
            return False

    return True

is_all_berries(["strawberry", "raspberry", "blackberry", "currant"]))

def is_berry(fruit):
    """Return True if fruit is a valid berry.

    Valid berries are "strawberry", "raspberry", "blackberry", and "currant".
    There are no other valid berries. For example, "berry" is not a valid berry.
is_all_berries(["apple", "berry", "cherry"]))

type or paste code here

Notice that you quoted code is not all inside the code fence lines.

Edit: removed wrong guess.

"""Return True if all items in fruits are valid berries."""

calling the function

You need to help us help you.

What is it that you do not understand?

Please, please, learn to use the </> quote code feature correctly!

I’m so sorry, totally new here let me organize the code

now please check

You still did not ask a question. I am guessing that your question may be this:

How do you want is_berry to decide?

is_all_berries function relies on the is_berry function so I need to complete is_berry function
but I’m stuck on how i do call ?

Your call to is_berry(fruit) is correct in is_all_berry.

What you need now is to implement the code in is_berry.

Describe in words what is_berry will do to know that a fruit is a berry.
Can you then turn that description into code?

if not is_berry(fruit):
NameError: name 'is_berry' is not defined

every time gives me error I think I’m not doing code correctly

Are you running this code from a file or typing it into the python prompt?

A suggest you put all the code in a file and run it as from the file.

Windows: py
Mac or linux: python

Does the code work then?

both functions are in the same file, and I’m using vs. code the problem is I’m not defining the is_berry because I don’t know how to define this is my first program to call the function, so I’m confused about how I code in is_bery function.

Have written the code into is_berry?
The code above only has a doc string and not any statements.

def is_berry(fruit):
     print(‘is berry called’)
     return False

yes, but didn’t work. above code has only a doc string because we need to write the code

YOU need to write the code.

Please write the code!

Well, the function definition begins:

 def is_berry(fruit):

Ignoring that it is a function, can you write an if-statement to test
whether a variable fruit is one of the required berry names? Maybe
make it print “yes” or “no” depending on the test.

Cameron Simpson

The is_all_berries() function calls the is_berry() function. To do this, is-berry must be defined first.
Change the code sequencing, then add a debug-print to is_berry() - see @Barry’s suggestion, and execute to prove that the outer function calls the inner.
That should answer the title-question.
Lastly, replace the debug-print in is_berry() with the actual code necessary. (am assuming this is a course-assignment, so will leave that to you)
Regards =dn

@barry <> @barry-scott :smiley: