Reputation: 21
def winners(finish_order, teams):
return finish_order[0], 'and', teams[finish_order[0]], 'won the race!'
print(winners(['Green', 'Zelda', 'Frog'], {'Zelda':'Midna', 'Frog':'Frogette', 'Green':'Red'}))
So running the code above prints ('Green', 'and', 'Red', 'won the race!'). How do I print Green and Red won the race! instead? Basically, I want to print elements from the list without the extra parentheses and quotations, when using them in a sentence.
Upvotes: 1
Views: 30
Reputation: 195603
Return formatted string, not tuple:
def winners(finish_order, teams):
return '{} and {} won the race!'.format(finish_order[0], teams[finish_order[0]])
print(winners(['Green', 'Zelda', 'Frog'], {'Zelda':'Midna', 'Frog':'Frogette', 'Green':'Red'}))
Prints:
Green and Red won the race!
Upvotes: 1