[Tutor] Is there a qucker method than the following?

Luis N tegmine at gmail.com
Fri Aug 5 21:54:37 CEST 2005


On 8/5/05, Nathan Pinno <falcon3166 at hotmail.com> wrote:
>  
> Hi all, 
>   
> Is there a quicker method than the following? 
>   
> import random
> numbers = [0,1,2,3,4,5,6,7,8,9,10,11,12]
> cards =
> ["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"]
> hand = {numbers:cards} 
>   

hand is invalid syntax, list objects are unhashable. deal() is also
invalid syntax, and will throw a type error. Fixing these might show
you a way to do things quicker. List comprehensions might be useful to
you in this context.

Luis.


More information about the Tutor mailing list