0

this task is not clear to me. Please help. Explain.

fruits=["apple","banana","cherry","kiwi","mango"] newlist=[] for x in fruits: if "a" in x: newlist.append(x) print(newlist)

15th Dec 2021, 11:03 AM
Сузана Ажыбекова
Сузана Ажыбекова - avatar
1 Odpowiedź
+ 7
Well it simple to understand let's start from 1st line 1) its list of fruit names you know 2) it's an empty list where later on mew items will be added 3) this is a for loop iterating over the list of fruit means, this loop will run for 5 times with one fruit name contained in x at one time execution. 4) now as fruit name comes to x there is a condition to check if the fruit is containing letter "a". 5) if letter "a"is found then add it to list newlist that's all So the result will be apple, banana, mango
15th Dec 2021, 11:10 AM
Ayush Kumar
Ayush Kumar - avatar