lundi 22 février 2016

Using a dictionary and randomly choosing a value from multiple options

this is my first time asking a question, i hope this will be specific, anyway, i made a list with 3 values inside it, it looks like this """A = ["+","-","*"]""" and basically i have this line later on """a = random.choice(A)""" so its some work where i have to make a random quiz using those 3 operators, and i was told i have to use a dictionary to attain a higher mark, however, i am not sure how to make a dictionary 'key' with the 3 operators attached, AND, the operator has to be randomly selected. but i have no idea how to randomly select a value from a dictionary and use it in an if statement thanks!




Aucun commentaire:

Enregistrer un commentaire