> On Mon, Feb 18, 2013 at 10:22 AM, Niclas Rautenhaus > <n.rautenh...@gmx.de>wrote: > >> Hello folks,**** >> >> ** ** >> >> I would be very pleased if someone is able to help me.**** >> >> I wrote a small programm, to calculate the grand total for a car.**** >> >> A basic price can be entered. Given that basic price, a tax peercentage >> is >> calculated and added tot he grand total.**** >> >> >> But unfortunately I am stuck with giving the user the choice to select >> an >> additional option! >> The extra items have got set values, but at the moment they all get >> summarized, but i want to choose. >> >> ** >> > > > greetings Niclas, and welcome to Python! while i'll let the others comment > on your code specifically, i can give some overall suggestions/guidance. > > you're trying to create an overall price calculator correct? while it's > straightforward providing a base price, the complexity in your app (and > real life) is the set of options that customers can choose from. > > 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 } Comments? _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor