Я пишу числа в текстовый файл, и это работает, но проблема в том, что он не печатает первое число.
Если я пишу 1 2 3 4 5 6, тогда у меня естьсторожевой цикл и используйте -1 до конца.
Будет напечатано 2 3 4 5 6
outfile = open("userInput.txt","w")
userInput = int(input("Enter a number to the text file: "))
count = 0
if int(userInput) != -1:
while(userInput) !=-1:
userInput = int(input("Enter a number to the text file: "))
outfile.write(str(userInput) + "\n")
count+=1
if count == 0:
print("There is no numbers in the text file")
outfile.write("There is no numbers in the text file")
count+=1
outfile.close()