+ 2

How do I print the following on Python?

Suppose I made a list : [ā€˜apple’ , ā€˜orange’ , ā€˜pear , ā€˜kiwi’] And I went through a filtering process in a for loop Which filtered ā€˜apple’ and ā€˜kiwi’ out. I would like the result to be: apple and kiwi chosen But i don’t know how to add the ā€˜and’ between two items from the list and printing them individually, with the ā€˜chosen’ at the end. Plus, the result would be diferrent everytime e.g if only orange is chosen, it’ll print: orange chosen Thanks!

1st Oct 2019, 9:32 AM
SquareGrids
SquareGrids - avatar
1 Answer
+ 6
Why not select Apple and Kiwi into a new list called k? Then, you can do: print(*k, sep=" and ", end="chosen.")
1st Oct 2019, 9:55 AM
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬ - avatar