[Tutor] Display all field of a listuples

Alex Hall mehgcap at gmail.com
Thu Feb 24 23:09:26 CET 2011


On 2/24/11, Christopher Brookes <chris.klaitos at gmail.com> wrote:
>   Hi i would like to display all the field of my powerAll like this :
>
> Choose a power :
> Froid devorant : Embrase lenemi et le feu bruler
> Flammes infernales : 'Gele lenemi sur place
>
> -----------------------------
> class Character():
>   def ChoosePouvoirUnique(self):
>         print ("Choose a power")
>         for Power in powerAll:
>             print (Power)
You need a __init__() function in this class, as with any class.
>
> class Power:
>     def __init__(self, name, desc):
>         self.name = name
>         self.desc = desc
>
>
>
>
> powerAll = [
>  Power('Flammes infernales' , 'Embrase lenemi et le feu bruler'),
>  Power('Froid devorant', 'Gele lenemi sur place')]
>
>
> But he won't display it :(
How are you calling it? That is, what code are you using to try to
display the contents of the list? Is powerAll supposed to be a
variable in a class? If so, it should be self.powerAll.
>
> i've try   For PowerName,PowerDesc in powerAll:
>                 print (PowerName, PowerDesc)
>
> but it doesn't work !
What does that mean? It prints something strange, or you get an error?
What error is it? Also, "for" should be lowercase, though I am
honestly not sure that this is a requirement(though I believe it is).
>
> Thank you again..
>
> --
> Brookes Christopher.
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap


More information about the Tutor mailing list