Why is it that if input 1, line 1 isn't deleted in a.txt?

x = open('a.txt','r')
l = []
q = 0
for line in x:
	l.append(str(line))
b = "".join(l)
print b
a = raw_input("Which line do you want to delete?: ")
l[int(a)] = ""
x.close()
x = open('a.txt','w')
x.write(b)
x.close()

Solved:

x = open('a.txt','r')
l = []
q = 0
for line in x:
	l.append(str(line))
b = "".join(l)
print b
a = raw_input("Which line do you want to delete?: ")
l[int(a)] = ""
b = "".join(l)
x.close()
x = open('a.txt','w')
x.write(b)
x.close()
Member Avatar for leegeorg07

are you sure that it is deleting line a? from a quick glance it looks to me like it isn't

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.