I need to read the file called, "ranks.dat", however whenever I try opening the file it says there is no such file or directory even though I have downloaded the file. Below is my code:
# Reading from a file numFile = open("ranks.dat", "r") while True: text = numFile.readline() #rstrip removes the newline character read at the end of the line text = text.rstrip("\n") if text=="": break print (text, end = "\t") numFile.close() The files should always have the following fields: Rank - Word of Size 15 or less - the Name of the Card Power - Integer less than 100 - the Power of the Card Number - Integer less than 100 - the Number of these cards
I need to store each of the fields into their own list. But it does not seem to work.
ranks.datavailable to the program. Try copying it to the same folder as your script.