Python Forum
Homework advice - Boolean function, whole-word values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Homework advice - Boolean function, whole-word values
#1
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.
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
Reply


Messages In This Thread
Homework advice - Boolean function, whole-word values - by musicjoeyoung - May-07-2020, 03:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Basic Boolean homework help StillAnotherDave 9 3,665 Nov-27-2019, 12:38 PM
Last Post: StillAnotherDave
Exclamation A function that takes a word and a string of forbidden letters pooyan89 5 4,793 Jun-12-2019, 09:44 PM
Last Post: nilamo
  Storing Minimum List of values from a recursive function sigsegv22 1 2,576 Sep-10-2018, 01:25 PM
Last Post: ichabod801
  Help with homework problem - iterating a function midnitetots12 4 3,573 Feb-21-2018, 10:51 PM
Last Post: nilamo
  define all function, interogate list, boolean blacksaber 3 3,538 Jan-17-2017, 12:51 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020