Error message when I use function for file

48 views Asked by At

What is going wrong here? I try to read my txt file in a function.. :

def vragen_ophalen():
    text_file = open("vragen.txt", "r")
    print(text_file.read())



def main():
    vragen_ophalen()

if __name__ == "__main__":
    main()  

Error message:

Traceback (most recent call last):
  File "/Users/buni/Desktop/Leiden/iipr/Huiswerk python/sorteerhoed_concept.py", line 11, in <module>
    main()  
  File "/Users/buni/Desktop/Leiden/iipr/Huiswerk python/sorteerhoed_concept.py", line 8, in main
    vragen_ophalen()
  File "/Users/buni/Desktop/Leiden/iipr/Huiswerk python/sorteerhoed_concept.py", line 2, in vragen_ophalen
    text_file = open("vragen.txt", "r")
FileNotFoundError: [Errno 2] No such file or directory: 'vragen.txt'
0

There are 0 answers