[Solved] Why is this basic python program not working?
Your problem is this line subbed = line[-3:] This returns the following: ok\n or il\n Thus, your if statement checking if subbed == ‘ok’ will fail every time. You can fix this by only taking the last two characters, after stripping the newline: subbed = line.strip()[-2:] My original answer didn’t account for reading from a … Read more