#!/usr/bin/env python #-*- coding: iso-8859-1 -*- h = { 1 : { "name" : "Bananen", "price" : 2.95 }, 2 : { "name" : "Birnen", "price" : 1.95 }, 3 : { "name" : "Pflaume", "price" : 0.99 }, 4 : { "name" : "Zitrone", "price" : 0.45 } } hk = h.keys() hk.sort() for i in hk: print "ID: " + str(i) + "\t" + h[i]['name'] + "\t" + str(h[i]['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: print 'Produkt "' + h[i]['name'] + '"\t(ID: ' + str(i) + ')\t\tzum Preis von ' + str(h[i]['price']) + ' Euro.' sum += h[i]['price'] print 'Der Gesamtpreis betrÃĪgt ' + str(sum) + ' Euro.'