#!/usr/bin/env python #-*- coding: iso-8859-1 -*- h = {1 : {"Apfel" : 0.29}, 2 : {"Birne" : 0.34}, 3 : {"Pflaume" : 0.09}, 4 : {"Zitrone" : 0.40}} hk = h.keys() hk.sort() for i in hk: prod = h[i].keys()[0] price = h[i][prod] print "ID: " + str(i) + "\t" + prod + "\t" + str(price) best = [] while True: inp = raw_input("ID der Bestellung: ") if inp == "Ende": break inp = int(inp) if h.has_key(inp): best.append(inp) else: print "Fehler: Produkt nicht vorhanden." print print "Rechnung:"; print "Bestellt wurde:"; sum = 0 for i in best: prod = h[i].keys()[0] price = h[i][prod] print 'Produkt "' + prod + '" (ID: ' + str(i) + ') zum Preis von ' + str(price) + ' Euro.' sum += price print 'Der Gesamtpreis betrÃĪgt ' + str(sum) + ' Euro.'