Please help in finding out the error

def listemails(’/home/kretikatiwari999632/GYB-GMail-Backup kretika.tiwari99@gmail.com’,select=[‘to’, ‘from’,‘subject’], where=‘subject’, matches=’.+’):
return[‘to’,‘from’,‘subject’]
listemails(’/home/kretikatiwari99963/GYB-GMail-Backup-kretika.tiwari99@gmail.com’, select=[‘to’, ‘from’, ‘subject’], where=‘subject’, matches=’.+’)

syntax error…

While defining a function, you should mention a variable name in argument and while calling the function we use the literal value.

For example:

# This is defining a function. 
def mysq(x):
      return x*x

# This is calling a function once with x as 10 and once with x as 20.
mysql(10)
mysql(20)

Hi, Kretika.

You have to write this inside the for for loop for os.walk() function, where you can read the folder and extract the email and the text, which defines “to”,“from”,“subjects”.

  1. Parse the email by parsed_eml.
  2. Use parsed_eml[‘header’][‘from’] --> to get the info about the from where you got the email.
  3. parsed_eml[‘header’][‘to’] --> To whom the email has been sent.
  4. parsed_eml[‘header’][‘subject’] --> What is the subject of the email.

and then put this inside the function listemails("").

All the best