Need help in the below code:
langs=['C','Java','Cobol','Python']
f1=open('a.txt','r')
f2=open('abc.txt','w')
for index in range(len(langs)):
for line in f1:
f2.write(line.replace('Frst languag','langs[index]'))
f1.close()
f2.close()
Line #4: Not sure if the syntax is correct, all i want is the loop to run for n number of times where n is no. of values inside the list.
Line 6:
All I need is everytime the loop to run and each time langs[0] value #should be written to the file, then langs[1] value and so on...
range(len(langs))and referring tolangs[index]is an anti-pattern in Python. Just usefor lang in langs: