> in your situation, i think it would be more "Pythonic" to maintain the
> > extras as a vector of options and prices. you then loop through those,
> > prompting the user to enter Yes or No, and add either the cost or zero,
> > respectively. that will help keep your code less complex as well. you
> > would
> > just be maintaining a running total until the user is done with all their
> > selections.
> >
> > good luck!
> > -- wesley
>
> I'd be interested in knowing exactly what you mean by the term "vector" in
> the above discussion. When I saw the problem I thought dict would serve
> as in
>
> options = { "leather" : 1600, "alloy_wheels" : 1200,
> # and so on
> }
perfectly fine if order doesn't matter. if it does, then a tuple will serve
a similar purposes however, it's easy to move back-n-forth between either
via dict(), dict.items(), iter/zip(), etc.
cheers,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A computer never does what you want... only what you tell it."
+wesley chun : wescpy at gmail : @wescpy
Python training & consulting : http://CyberwebConsulting.com
"Core Python" books : http://CorePython.com
Python blog: http://wescpy.blogspot.com
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor