Comparing Two Lines In Opened Files With For Loops

Okays guys this code works but not as i want it , If anyone could help I want it to take the first line in hash_replace and check through every single line in hash_found until it finds one , but this code just compares them side by side.If anyone could help i would be grateful.

with open('resolute','r') as renny:
    with open('ronny','r') as renna:
        for line,line2 in zip(renny,renna):
            lin = line.split()
            li = line2.split()
            hash_to_replace = lin[2]
            email = lin[0]
            hash_found = li[0]
            pass_found = li[2]
            if hash_to_replace == hash_found:
                print('Found')
            else:
                print('Nothing')

Upvotes: 0

Views: 50

Answers (1)

Scott Hunter
Scott Hunter

Reputation: 49813

You need 2 nested loops: for each line, loop over all of the line2s:

with open('resolute','r') as renny:
    for line in renny:
        with open('ronny','r') as renna:
            for line2 in renna:

Upvotes: 1

Related Questions