On 01/11/2013 09:24 AM, Matt Jones wrote:
Pay isn't linked to the "people" in any way. A dictionary would serve this purpose better (at least in this simple example).

database = {
    'Mac' : 1000,
    'Sam' : 2000
}

name = raw_input('Enter your name:')
if name in database.keys(): print "your pay is $", database[name]


This can be simplified a bit as:

database = dict(Mac=1000, Sam=2000)
name = raw_input('Enter your name: ')
if name in database:
  print "your pay is $", database[name]



 -m



--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to