Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #16651

Re: class print method...

References <CALKjt2fen-uZ==A=KJ=-C8JAufU4vmeZQqyW1=3sWR6ajOpXhw@mail.gmail.com> <4EDC775D.4000906@davea.name> <CALKjt2dTF=k-2pQy7YQPsEWexWGK5ej5w721Es+BtQnnoHghDg@mail.gmail.com> <CALKjt2caxDh_GBwtBaNDzF6=Q=tPpyNe4db1BeUX16zda-XvhQ@mail.gmail.com>
Date 2011-12-05 22:35 +1100
Subject Re: class print method...
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3296.1323084954.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Dec 5, 2011 at 10:18 PM, Suresh Sharma <ss27051980@gmail.com> wrote:
>
> Suit=[aces,clubs,diamonds,hearts]
> Rank=[2,3,4,5,6,7,8,9,j,Q,K,A]
> class Card:
> Def __init__(self,rannk,suiit):
> Self.suiit=suiit
> Self.rannk=rannk
>
> Def __str__(self):
> Return suit[suiit],rank[rannk]
>
> Class deck:
> Def __init__(cards):
> Self.cards=[ ]
> For suit in range(4):
> For rank in range(13):
> Self.cards.append(Card(suit,rank))
>
> Def __str__(self):
> s = ""
> For card in self.cards:
> S = str(self.cards)
> Return s.

Python is case sensitive, and indentation is significant. Paste your
code exactly as you're trying to run it, and we'll be better able to
help you.

Chris Angelico

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: class print method... Chris Angelico <rosuav@gmail.com> - 2011-12-05 22:35 +1100

csiph-web