Re: help

Discussion in 'Python' started by Mitya Sirenef, Jan 11, 2013.

  1. 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/
    Mitya Sirenef, Jan 11, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?dHJlbGxvdzQyMg==?=

    HELP! HELP! HELP! Opening Web Application Project Error

    =?Utf-8?B?dHJlbGxvdzQyMg==?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    758
    =?Utf-8?B?dHJlbGxvdzQyMg==?=
    Feb 20, 2004
  2. Harvey
    Replies:
    0
    Views:
    691
    Harvey
    Jul 16, 2004
  3. Harvey
    Replies:
    1
    Views:
    834
    Daniel
    Jul 16, 2004
  4. =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?=

    HELP - HELP - HELP

    =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?=, Mar 9, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    677
    Eliyahu Goldin
    Mar 9, 2006
  5. Buster

    Help, Help, Help

    Buster, Oct 4, 2003, in forum: Java
    Replies:
    3
    Views:
    469
    Saager
    Oct 30, 2003
Loading...

Share This Page