Python Forum

Full Version: Trying to append List/array based on condition
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm having problems appending array based on an if statement.

all_staff = ["Judith", "Harry", "Jonathan", "Reuben"]
new_staff = []


def person_finder(staff):
    for x in staff:
        if x == "Reuben" or "Harry" or "Jonathan":
            new_staff.append(x)
        else:
            continue
        return new_staff


selected = person_finder(all_staff)


def the_men(people):
    for x in people:
        print(x + " is a man" .format(people))


the_men(selected)
This returns:

Judith is a man
(Mar-20-2018, 12:18 PM)Mr_Keystrokes Wrote: [ -> ]
if x == "Reuben" or "Harry" or "Jonathan":

That isn't doing what you think it's doing. Head over this way, and read this :) https://python-forum.io/Thread-Multiple-...or-keyword