Skip to content

Instantly share code, notes, and snippets.

@FLAK-ZOSO
Created January 26, 2022 09:45
Show Gist options
  • Save FLAK-ZOSO/74054e070899035bb2187f1c10ca2008 to your computer and use it in GitHub Desktop.
Save FLAK-ZOSO/74054e070899035bb2187f1c10ca2008 to your computer and use it in GitHub Desktop.
with open('file.txt', 'r') as file:
lines = file.read().split('\n') # lines is a list of the lines of the file
dictionary: dict = {}
for index, line in enumerate(lines):
line = line.split(' ')
dictionary[str(index)] = {
"white": line[0],
"black": line[1],
"white score": line[2],
"black score": line[4]
}
print(dictionary)
fischer morphy 1 - 0
carlsen alekhine 0 - 1
kasparov capablanca 1/2 - 1/2
@hauzan2112
Copy link

been answered

for items in dictionary.values():
    if items["white score"] and items["black score"] == "1/2":
        print("game between white player,", items["white"], "and black player,", items["black"], "ended up in draw")

@FLAK-ZOSO
Copy link
Author

Yes, does it work?

@hauzan2112
Copy link

it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment