[Solved] Removes non-vegetarian foods from a list of foods. [closed]


def veggie_r_ip(foods, curIndex):
    if(curIndex >= len(foods)):
        return
    curFood = foods[curIndex]
    is_veggie = curFood.split('|')[2]
    if is_veggie == "False":
        foods.remove(curFood)
        veggie_r_ip(foods, curIndex)
    else:
        veggie_r_ip(foods, curIndex + 1)

def main():
    foods =['Spicy Vegetable Moo Shu|1|True|140', 'BBQ Pork|1|False|920', 'Chicken Breast|1|False|920', 'Salad|1|True|920']
    veggie_r_ip(foods, 0)
    print foods

1

solved Removes non-vegetarian foods from a list of foods. [closed]