moved if temp>freq in highest frequency outside the inner loop, as it should be

This commit is contained in:
K 2023-12-11 09:12:31 +05:30
parent a78f6deacc
commit d8ad39d234
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F

View File

@ -63,8 +63,8 @@ def high_freq():
for j in range(len(marks)): # Iterate through marks list using j again for j in range(len(marks)): # Iterate through marks list using j again
if (marks[i] == marks[j]): if (marks[i] == marks[j]):
temp_count+=1 temp_count+=1
if (freq_count < temp_count): # If temp_count is greater than freq_count value, then if (freq_count < temp_count): # If temp_count is greater than freq_count value, then
freq_count = temp_count # Make freq_count equal to temp_count freq_count = temp_count # Make freq_count equal to temp_count
print(f"\n-----\nHighest frequency is:\t{freq_count}\n-----") print(f"\n-----\nHighest frequency is:\t{freq_count}\n-----")
def main(): def main():