1
I am creating a function in python3 and a question arose about the use of Return, when we call him in the code he must terminate the function immediately?
In the code below this is not working, even when the if is satisfied, it finishes the entire loop of the code, to then give the return.
def find_msg_by_parameter(parameter, search_term, email_folder):
client = client_connect()
results = client.users().messages().list(userId='me', labelIds = [email_folder]).execute()
for id_mail in results['messages']:
id_msg = client.users().messages().get(userId='me', id=id_mail['id']).execute()
id_msg_df = pd.DataFrame(id_msg['payload']['headers'])
msg_header = id_msg_df[id_msg_df.name==parameter].value.iloc[0]
if check_name(search_term,msg_header):
return id_mail
print('Buscando')
print('Não encontrado')
The function check_name returns a boolean.
I was able to find out what the problem was, the list that is iterated is generated with random ordering, the Return was working correctly, I did not pay attention to this detail. Thank you!
– BRUNO FLAKS