May-07-2020, 03:02 PM
Folks on here were so quick to help with my first question--I appreciate everyone who replies!
I completed a task assigned to me, but I'm missing some clarifying piece.
Here's my code which make sense to me:
Any help is greatly appreciated!
-a brand new student to this
I completed a task assigned to me, but I'm missing some clarifying piece.
Quote:Instructions:
create this program with a Boolean function bird_available()
- has parameter that takes the name of a type of bird
- for this exercise the variable bird_types = 'crow robin parrot eagle sandpiper hawk pigeon'
- return True or False (we are making a Boolean function)
- call the function using the name of a bird type from user input
- print a sentence that indicates the availability of the type of bird checked
Here's my code which make sense to me:
def bird_available(bird): bird_types = 'crow, robin, parrot, eagle, sandpiper, hawk, pigeon' return bird.lower() in bird_types bird_input = bird_available(input("Type bird name here: ")) print("The bird is available T/F: ", bird_input)Here's some normal, expected, and correct output examples:
Output:Type bird name here: crow
The bird is available T/F: True
#or
Type bird name here: dog
The bird is available T/F: False
What happens, though, is that if I type in any consecutive letters from the values in bird_types, I get True. (e.g., "ro" from "crow", or "pig" from "pigeon")Output:Type bird name here: ro
The bird is available T/F: True
Can someone help on how to address that aspect? I feel like the answer has something do to with the variable bird_types but I can't figure out what to do.Any help is greatly appreciated!
-a brand new student to this