Обясните пожалуйста | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Обясните пожалуйста

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

15th Dec 2021, 10:54 AM
Сузана Ажыбекова
Сузана Ажыбекова - avatar
2 Respuestas
+ 1
Its as simple as it appears. You have 2 baskets one with some fruits in it, and another is empty.(line 1,2) Now from available fruits in basket 1 your are picking a fruit one by one.(line 3) Now you are checking if there is an "a" in the fruit name. If yes then you put that fruit in blank basket.(line 4,5) At the end you are showing your basket with fruits with "a" in their name.
15th Dec 2021, 12:18 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 1
thank you very much 
15th Dec 2021, 12:29 PM
Сузана Ажыбекова
Сузана Ажыбекова - avatar