Python Function Wrap Output

Asked 1 years ago, Updated 1 years ago, 261 views

def fruit(*fruits):
    if "apple" in fruits :
        print("RED")
    print(*fruits)           

fruit('banana', 'apple', 'mango')

In the code that inputs fruits with variable factors and outputs RED if there is an apple during *fruit, the error is It doesn't show, but the output is

RED
banana apple mango

That's what it says. By the way, I'm

banana
apple
RED
mango

You can't even use \n to make a line between words. I want it to be printed like this, so how can I fix it??

python

2022-10-14 01:00

1 Answers

It's too basic. What was difficult?

    for f in fruits:
        print(f)


2022-10-14 01:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.