[Tutor] Dictionnaries in object
Corey Richardson
kb1pkl at aim.com
Thu Feb 24 20:04:15 CET 2011
On 02/24/2011 01:58 PM, Christopher Brookes wrote:
> Hi,
>
> I want to create some powers in my fight program.
> I want to know if dictionnaries is the best solution to do it.
>
> For now its look like this :
>
>
> //French name and description, don't care about it ;)
>
> power1= {}
> power1['Name'] = 'Flammes infernales'
> power1['Description'] = 'Embrase lenemi et le feu bruler'
>
> power2= {}
> power2['Name'] = 'Froid devorant'
> power2['Description'] = 'Gele lenemi sur place'
>
> powerAll= [power1,power2]
>
> but if i want to create like 20 powers, it will be long no ? is there any
> solution shorter (and better ?)
>
> Thank you for reading,
powerAll = {"Flammes infernales": "Embrase lenemi et le feu bruler",
"Froid devorant": "Gele lenemi sur place"}
Have it implicit that the key is the name and the value is the
description. That's how I would do it, at least.
--
Corey Richardson
More information about the Tutor
mailing list