I am trying to mak9e a love calculator, but it is throwing error that, score_total is not defined, I tried many things but it just doesn't works. I try to define it globally.
When I defined it globally as score_total=0. It just doesn't return from function, it keeps its value 0 outside the function. I am a beginner.
boy = input("Enter boy Name\n").casefold()
girl = input("Enter girl name\n").casefold()
#score_total=
vowel_a =0
vowel_b=0
boyl=None
girll=None
boyl=len(boy)
girll=len(girl)
#print(boyl)
cons_a =0
cons_b=0
for i in range(boyl):
if boy[i] is 'a' or 'e' or 'i' or 'o' or 'u':
vowel_a+=1
for i in range(girll):
if girl[i] is 'a' or 'e' or 'i' or 'o' or 'u':
vowel_b+=1
for i in range(len(boy)):
if boy[i] is 'z' or 'b' or 't' or 'h':
cons_a +=1
for i in range(len(girl)):
if girl [i] is 'z' or 'b' or 't' or 'h':
cons_b+=1
def calculation(a,b,score_total):
score_total = 1
if len(a) == len(b):
score_total += 20
elif len(a)!=len(b):
score_total += 7.4
if a[0] and b[0] is 'a' or 'b' or 'c' or 'd' or 'e':
score_total +=10
else:
score_total+=3.7
if a[0] and [b] is 'z' or 'b' or 't' or 'h':
score_total+=5
else:
score_total +=1.16
if vowel_a == vowel_b:
score_total +=12
else:
score_total +=3.67
if cons_a == cons_b:
score_total+=12
else:
score_total+=4.56
if a[0] is 'i' or 'v' or 'o' or 'l':
score_total+=7
else:
score_total+=5.6
#return int(score_total)
print(score_total)
#print(scor--
calculation(boy,girl,1)
if score_total < 50:
if score_total%2 ==0:
score_total+=30
elif score_total>100:
temp = score_total-100
score_total -= temp
else:
score_total+=24
import time
print("Calculating Result...........\n")
time.sleep(3)
print("Data processing...")
time.sleep(7)
print(f'The love between {boy} and {girl} is {score_total}%' )