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