For folks like me looking at the accepted answer, and not understanding why it's not working, you need to add quotes around your sub directory, in the green checked example,
x_file = open(os.path.join(direct, "5_1.txt"), "r")
should actually be
x_file = open(os.path.join('direct', "5_1.txt"), "r")