Properly name your topics
hello i am working on a program and need some assistance. essentially the part of the program im working on opens a text file and iterates through each line of the file to basically see whether or not that line in the file is either valid or invalid. the proble im having is i can't get the lines that come back valid to save to a seperate text file than. ive tried different varriations of for loops if statements and T/F and no luck. im very new to programming so any help is appreciated.
for example:
try:
good = 'valid'
f = open('xxx.txt', 'r')
f2 = open('yyy.txt', 'a')
list = open('xxx.txt').readlines()
for i in list:
f.readlines()
try:
url = 'https://xxx.com/' + i
html = requests.get(url).text
data = json.loads(html)
print(data.get('r').get(''))
time.sleep(5)
if i in list == good:
f2.writelines()
for example:
try:
good = 'valid'
f = open('xxx.txt', 'r')
f2 = open('yyy.txt', 'a')
list = open('xxx.txt').readlines()
for i in list:
f.readlines()
try:
url = 'https://xxx.com/' + i
html = requests.get(url).text
data = json.loads(html)
print(data.get('r').get(''))
time.sleep(5)
if i in list == good:
f2.writelines()