Help
So, I'm still a starter on python and I decided to make a simple program that, when you tell it the ingredients you have in your home, it tells you some recipes to make.
I decided to make it based on a text file, which means I will have a text file with the ingredients sorted out on it, and if the ingredients the person typed in match the ones on the file, it will read the line under them, which will contain a path for another text file which will have the full recipe for the person to read.
The code works IF there is no line under the line with the path to the file. Which is weird, because when I changed it to print, not open the file path, it printed it out correctly, but when I try to make python open it, it displays this error message:
Traceback (most recent call last):
File "C:/Users/nailu/PycharmProjects/Recipe find yes/find rcipe.py", line 66, in <module>
g = open(file.readline())
OSError: [Errno 22] Invalid argument: 'C://Users//nailu//Desktop//Projeto receita//Receitas//receita bolo de maca.txt\n'
please help, it keeps saying theres a \n in there when there isnt!
Here is the code in case you guys need some context
word=input("Digite aqui:")
count = 1
count2 = 1
s=" "
while (s):
s = file.readline()
L = s.split()
if palavro in L:
print("I found a recipe for you!")
time.sleep(1)
see=input("Would you like to see it? y/n")
if see=="y":
g = "a"
g = open(file.readline())
h=" "
while (h):
h = g.readline()
print(h)
count2= (count2+ 1)
time.sleep(1)
else:
print("Ok, going over to the next recipe...")
time.sleep(0.5