lundi 10 avril 2017

Trying to learn how to use python random.choice()

I am incredibly new to programming so please bear with me. I tried searching for the answer to my question with previous posts but had no luck there. My issue is that I am reading a beginner book for python and in it they give an example of how to use random.choice for python 2.7. This example is as follows;

import random

t = [1, 2, 3]
random.choice(t)

the book then shows a result from 1 to 3. This didn't work for me and I even tried putting;

print t

but all I get is [1, 2, 3,] printed as a result.

Thank you for any help you can give me and sorry I am so new at this! If I am posting in the wrong place feel free to point me in the right direction, thanks!




Aucun commentaire:

Enregistrer un commentaire