-1
@client.command()
async def show(ctx, player, *args):  # General stats
    rs = requests.get(apiLink + "/checkban?name=" + str(player))
    if rs.status_code == 200:  # HTTP OK
        rs = rs.json()
        joined_array = ','.join({str(rs["otherNames"]['usedNames'])})
        embed = discord.Embed(title="Other users for" + str(player), 
        description="""User is known as: 
        """ +joined_array)
        await ctx.send(embed=embed)

enter image description here

My goal here is to have every username on different lines after each comma, and preferably without the [] at the start and end. I have tried adding joined_array = ','.join({str(rs["otherNames"]['usedNames'])}) but the response from the bot is the same as shown in the image.

Any answer or tip/suggestion is appreciated!

Se7en Axis
  • 59
  • 5
  • Does this answer your question? [How do I concatenate items in a list to a single string?](https://stackoverflow.com/questions/12453580/how-do-i-concatenate-items-in-a-list-to-a-single-string). You can simply use `",\n".join(your_array)` – TheFungusAmongUs Jul 13 '22 at 04:35

1 Answers1

0

Try this:

array = ['user1', 'user2', 'user3', 'user4', 'user5', 'user6'] #your list
new = ",\n".join(array)

print(new)

Output:

user1,
user2,
user3,
user4,
user5,
user6

In your case I think array should be replaced with rs["otherNames"]['usedNames']

User One
  • 287
  • 2
  • 9
  • 1
    This answer is unpythonic: [`enumerate` is preferred over `range(len())`](https://stackoverflow.com/q/63492062/16177247), even then, `join` replaces all this logic. – TheFungusAmongUs Jul 13 '22 at 04:35