python - return out of function -


this question has answer here:

hi im working on code not working because error: 'return' out of function

here code

def get_information():     names_list=[]     coursework_marks_list=[]     prelim_marks_list=[]      file=open("details.txt","r") line in file:     item=line.split()     if len(item)>1:         names_list.append(item[0])         coursework_marks_list.append(item[1])         prelim_marks_list.append(item[2])      return names_list,coursework_marks_list,prelim_marks_list 

indentation everything in python. return statement out of scope of function. need remedy so:

def get_information():     names_list=[]     coursework_marks_list=[]     prelim_marks_list=[]      file=open("details.txt","r")     line in file:         item=line.split()         if len(item)>1:             names_list.append(item[0])             coursework_marks_list.append(item[1])             prelim_marks_list.append(item[2])      return names_list,coursework_marks_list,prelim_marks_list 

you should read & follow pep 8 style guide python.


Comments