Dec-28-2021, 10:51 AM
Hi guys,
I have half of this code running. It's the other half that's busting my brain.
On second thought, when I run it outside of the function the first half works. Inside the function...no clue because I can't get the other half running.
Once again, your support is appreciated.
I have half of this code running. It's the other half that's busting my brain.
On second thought, when I run it outside of the function the first half works. Inside the function...no clue because I can't get the other half running.
Once again, your support is appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
buckets = [ ( 'john.doe@example.com' ,{ 'first_name' : 'john' , 'last_name' : 'doe' }), ( 'jane.doe@example.com' ,{ 'first_name' : 'jane' , 'last_name' : 'doe' }), ( 'derek.zoo@example.com' ,{ 'first_name' : 'derek' , 'last_name' : 'zoolander' }), ( 'murph.cooper@example.com' ,{ 'first_name' : 'murph' , 'last_name' : 'cooper' }), ( 'ned.stark@example.com' ,{ 'first_name' : 'ned' , 'last_name' : 'stark' }) ] def update_record(list_of_records, email, first_name, last_name): """ This function is created to reset the value of the first_name and last_name for a record found with a specific email address while leaving the rest of the list unchanged. If the email address does not exist, then append a new record to the list with the new email address, first name and last name. """ ## Write code below ## new_values = [] for k, v in enumerate (list_of_records): email, full_name = v #email = v[0] first_name = full_name[ 'first_name' ] last_name = full_name[ 'last_name' ] if 'email' = = email and 'first_name' ! = first_name and 'last_name' ! = last_name: full_name.update({ 'first_name' : first_name}) full_name.update({ 'last_name' : last_name}) # elif 'email' != email and 'first_name' != first_name and 'last_name' != last_name: # #email['email'].append('email') # full_name['first_name'].append('first_name') # full_name['last_name'].append(last_name) ## end of function ## update_record(buckets, 'john.doe@example.com' , 'jon' , 'snow' ) |