English, asked by kkdev4364, 10 months ago

The group_list function accepts a group name and a list of members, and returns a string with the format: group_name: member1, member2, … For example, group_list("g", ["a","b","c"]) returns "g: a, b, c". Fill in the gaps in this function to do that.

Answers

Answered by niveditamishra3011
9

Answer:

def group_list(group, users):

 return group + ": " + (", ".join(users) )

print(group_list("Marketing", ["Mike", "Karen", "Jake", "Tasha"])) # Should be "Marketing: Mike, Karen, Jake, Tasha"

print(group_list("Engineering", ["Kim", "Jay", "Tom"])) # Should be "Engineering: Kim, Jay, Tom"

print(group_list("Users", "")) # Should be "Users:"

OR

def group_list(group, users):

return "{} : {}".format(group,", ".join(users))

print(group_list("Marketing", ["Mike", "Karen", "Jake", "Tasha"])) # Should be "Marketing: Mike, Karen, Jake, Tasha"

print(group_list("Engineering", ["Kim", "Jay", "Tom"])) # Should be "Engineering: Kim, Jay, Tom"

print(group_list("Users", "")) # Should be "Users:"

Explanation:

Answered by jricha283
5

Answer:

def group_list(group, users):

 members = ", ".join(users)

 return "{}: {} ".format(group,members)

print(group_list("Marketing", ["Mike", "Karen", "Jake", "Tasha"])) # Should be "Marketing: Mike, Karen, Jake, Tasha"

print(group_list("Engineering", ["Kim", "Jay", "Tom"])) # Should be "Engineering: Kim, Jay, Tom"

print(group_list("Users", "")) # Should be "Users:"

Explanation:

Similar questions