mercredi 15 avril 2020

Python random module formatting

I have this problem. I'm trying to make a dice roll in python. But whenever i print its value it has [""] attached. Is there a way to remove this?

Example.

import random

choices = ["Heads", "The Coin landed on it's side. It's a draw!", "Tails"]
rancoin = random.choices(choices, weights = [10, 1, 10], k = 1)

print("{}".format(rancoin))

Outputs.

["Heads"], ["Tails"] or ["The Coin landed on it's side. It's a draw!"]

It's really annoying having the extra brackets and quotation marks, since i'm trying to make it post to a text channel.




Aucun commentaire:

Enregistrer un commentaire