How can i call the 2 functions at the same time or perform a mathematical operation from their results? Every time i call these two functions, only the first function stores the data while the second function shows 0?
fname= input("Enter a file name: ")
try:
openFile= open(fname, 'r')
except:
print(fname, "is not found in the directory.")
quit()
def linecount():
line_count= 0
for line in openFile:
if line.startswith("X-DSPAM-Confidence: "):
line_count= float(line_count+1)
return(line_count)
def contents():
spamContent= 0
for content in openFile:
if content.startswith("X-DSPAM-Confidence: "):
contentconversion= float(content[20:26])
spamContent= spamContent + contentconversion
return(spamContent)
result= contents()/linecount()
print(result)