I was required to create a list that includes at least three people Iād like to invite to dinner. Then use this list to print a message to each person, inviting them to dinner.
Code:
My_Guests = ['Charlie','George','Bennjamin','Winslow']
message ="You are invited to a dinner on the 5th August"
print(f'Guest invites:\n\tDear Mr {My_Guests[0]}, {message}\n\tDear Mr {My_Guests[1]}, {message}\n\tDear Mr {My_Guests[2]}, {message}\n\tDear Mr {My_Guests[3]}, {message}')
Output:
Guest invites:
Dear Mr Charlie,You are invited to a dinner on the 5th August
Dear Mr George,You are invited to a dinner on the 5th August
Dear Mr Benjamin,You are invited to a dinner on the 5th August
Dear Mr Winslow,You are invited to a dinner on the 5th August
Is there a simpler code to solving this problem?