I am trying to write a program in python where it reads a list of usernames from a file and sends a request to instagram to see if the username is available or not. Then it should prompt a message saying "THIS USERNAME IS AVAILABLE" or otherwise "THIS USERNAME IS TAKEN". I am having an error when trying to read my file that states 'FileNotFoundError: [Errno 2] No such file or directory: 'list.txt', even though the file is in my folder where the program resides.
I am also fairly new to python.
Here is my code currently:
import requests
filepath = 'list.txt'
separator = "\n" #Every time you use a newline it detects it as a new user
list = open(filepath, "r").read().split(separator)
notTaken = []
for i in list :
response = requests.get("https://instagram.com/" + i + "/")
if response.status_code == 404 :
notTaken.append(i)