delete a line in .txt using python by matching the number in the line
<p>I finally came to my last part.. and I'm stuck..</p>

<p>In my orderlist.txt file I have</p>

<pre><code>[99 ,1, "3/03/2011", ["ScrewDriver", "Hammer", "Stone"]]
[2 ,2, "3/03/2011", ["hammer,nails"]]
[31 ,2, "3/03/2011", ["plaster,studd"]]
[100 ,2, "3/03/2011", ["hammer,studd"]]
</code></pre>

<p>my code:</p>

<pre><code>def delorder():
    f=open('orderlist.txt',"r+")
    lines=f.readlines()
    num_del=int(input("what is the ordernumber to be deleted:"))
    new=""

    for line in lines:
        listline=eval(line)
        if not(num_del==list_line[0]):
            new +=(line + "\n")
        return (new)
</code></pre>

<p>at this part it give me</p>

<pre><code>Traceback (most recent call last):
  File "E:/cscs 120 testint in lab/assignment 1/Customer assignment 1/Customer assignment 1/testing oder", line 13, in &lt;module&gt;
    print(delorder())
  File "E:/cscs 120 testint in lab/assignment 1/Customer assignment 1/Customer    assignment 1/testing oder", line 8, in delorder
    listline=eval(line)
  File "&lt;string&gt;", line 1
    [99 ,1, "3/03/2011", [“ScrewDriver”, “Hammer”, “Stone”]]
                                      ^
SyntaxError: invalid character in identifier
</code></pre>

<p>My objective of this function is to get an input number example:31 and it will delete-->
[31 ,2, "3/03/2011", ["plaster,studd"]], which at the end in the orderlist.txt it would not appearr this line [31 ,2, "3/03/2011", ["plaster,studd"]] but the left over lines.
plz help</p>
