Q:

Can I include a for loop inside my print statement?

I have a list of winners of an event. I want to print them out at the end of my code, minus the brackets and quotes, and I am currently using:
            for items in winners:
                print(items)

Can I include this in a print statement?
I want:
            print("The winners of {} were: {} with a score of {}".format(sport, winners, max_result))

Is there a way of integrating the for loop into the print statement, or another way of eliminating the quotes and square brackets such that I can include it in the statement?
Thanks.

A:

You can't include a for loop but you can join your list of winners into a string.
winners = ['Foo', 'Bar', 'Baz']
print('the winners were {}.'.format(', '.join(winners)))

This would print

the winners were Foo, Bar, Baz.

