Minimum Number of Steps to Make Two Strings Anagram- Python3 related question

Hi, In the program to make the 2 strings anagram, I am getting separate output in 2 cases. In the first case I used 2 separate for loops to populate the values in the dictionary whereas in the second case I used the same for loop and zipped the contents to make the loop run.
Would someone please explain to me why my code runs with 2 separate for loops (Case ONE)
and fails when one single for loop is used (Case two)?

class Solution:
def minSteps(self, s: str, t: str) -> int:

    dict_s = {}
    dict_t = {}
    
    #case 1 with separate for loop
    for i in set(s):
        dict_s[i] = s.count(i)
    for j in set(t):
        dict_t[j] = t.count(j)
    
    #case 2 with same for loop for both the dictionary 
    """  
    for i, j in zip(set(s),set(t)):
        dict_s[i] = s.count(i)
        dict_t[j] = t.count(j)
    
    """
    count = 0
    
    for key,value in dict_s.items():
        if key in dict_t:
            if dict_t[key]<dict_s[key]:
                count+=abs(dict_t[key]-dict_s[key])
        elif key not in dict_t:
            count+=value
    return count
            
Comments (1)