+ 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!
1 Respuesta
+ 6
Why not select Apple and Kiwi into a new list called k?
Then, you can do:
print(*k, sep=" and ", end="chosen.")