r/programminghelp • u/nbaandothershit • Apr 18 '20
Python creating a new array using conditions on another array
Hey, hope you and your loved ones are safe from the pandemic!!
I would just like some help in how to go about creating a function in which I have a list of lists (called groceries) and a list of conditions. The function is meant to print out a new list that meets those conditions.
I thought about using a for loop inside a for loop but for some reason the result is always the groceries lists all merged into one massive list. Below is my pseudocode and should i not be putting a for loop inside another for loop? (ik this is a fairly simple problem but i really suck a coding lol)
def promotions(groceries, conditions):
promototions_lst=[]
for food in groceries:
for condition in conditions:
if condition[1]:
selection_lst += phone
else:
return False
print (promotions_lst)
1
u/SomeAverageJoey Apr 18 '20
Are you using correct indentation?