samedi 31 octobre 2015

Python 2.7 Attribute Error

I was wondering if it was possible for someone to assist me with an error I receive when using the 'random' function:

AttributeError: 'builtin_function_or_method' object has no attribute 'choice'

I have already imported the entire 'random' library and ensured there are no other files called 'random.py' in the same directory as where the file is saved.

Code:

from random import *

# Generates the random card

rank = ["Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"]
suit = ["Hearts", "Clubs", "Diamonds", "Spades"]

card_1 = ("The card is the %s of %s") % (random.choice(rank), random.choice(suit))




Aucun commentaire:

Enregistrer un commentaire