0

I'd like to receive a list of user aliases for the purpose of looking up an email. As of now, I can do this for only 1 input with the following code:

def Lookup(Dict_list):
    user_alias = raw_input("Please enter User Alias: ")
    data = []
    for row in Dict_list:

        #print "row test"
        #print row
        if user_alias in row.values():
            print row


    for row in Dict_list:
        if user_alias == row['_cn6ca']:
                email = row['_chk2m']
                print email
                return email

But I want to be able to have the user enter in an unknown amount of these aliases (probably no more than 10) and store the resulting emails that are looked up in a way that will allow for their placement in a .csv

I was thinking I could have the user enter a list [PaulW, RandomQ, SaraHu, etc...] or have the user enter all aliases until done, in which case they enter 'Done'

How can I alter this code (I'm guessing the raw_data command) to accomplish this?

4

2 に答える 2

2

これは、空の行 (または定義したセンチネル) に到達するまで入力を受け入れます。

#! /usr/bin/python2.7

print 'Please enter one alias per line. Leave blank when finished.'
aliases = [alias for alias in iter (raw_input, '') ]
print (aliases)
于 2013-10-15T21:25:09.207 に答える