I am learning python and need help understanding what I am doing wrong. The task I am trying to accomplish is create a list of integers from 1-100, and then create two other lists based off those numbers and finish by printing both lists. However, I am having trouble with getting the second list to write to a file named target list.txt. Can someone tell me what I am doing wrong?
num1 = input("Please Input a name for the file ending it with .txt. ")
numb_list = open(num1, "w")
mylist = []
def integer_list():
for numbers in range(1, 101):
mylist.append(numbers)
numb_list.write(str(numbers) + "\n")
print(numbers, end="\n")
integer_list()
print(mylist)
numb_list.close()
def target_list():
for numbers2 in range(25, 75):
mylist.append(numbers2)
target_list.write(numbers2+ "\n")
print(numbers2, end="\n")
target_list()
print(mylist)
target_list.close()