Question: Every time I run my piece of code it adds another \ when searching in my folder and then gives me an error. What do i do?
Repl link: https://replit.com/@EldonShabani/Alien?v=1
text_file = open("Charles_Darwin/module" + str(module) + ".txt", "r")
You put a \ instead of a /
Change line 63 to
text_file = open("Charles_Darwin/module" + str(module) + ".txt", "r")
But you should really use with
with open("Charles_Darwin/module" + str(module) + ".txt") as text_file:
content = text_file.readlines()
Because that automatically closes the file.
3 Likes