[Tutor] list, tuple or dictionary

Steven D'Aprano steve at pearwood.info
Wed Nov 30 00:22:03 CET 2011


ADRIAN KELLY wrote:
> i am trying to create a program that will allow users to enter items and their prices; should i be looking at a list, tuple or what?
> many thanksadrian


Translated to a version more familiar in the "real world":

    "I'm looking to build a wooden wardrobe that will allow
     the user to store their clothes. Should I be using a saw,
     a hammer, a drill, or what?"

The only correct answer is "Yes you should."

Lists, tuples and dicts are all basic tools in your programming toolbox, you 
should ALWAYS be looking at using them. But you use them for different purposes.

Perhaps if you narrow your question down to something more specific we can 
give a more useful answer.

Or... just try it! Don't be scared to write some code to throw it away. 
Especially when learning, there is no better way to learn than to write some 
code, discover what you can and can't do with the tools, learn the limitations 
by trying it, and then using that knowledge to write better code.


-- 
Steven


More information about the Tutor mailing list