I don't know how but it finnaly got to the point where it all works perfect.
Thanks for all your help

num=1
number_lst=[]
with open("C:\\write_it.txt", "r") as totals:
    for line in totals:

    print('% 04d %s' %(num, line),end = '')        
    line=line.strip().split('$')
    number_lst.append(float(line[1]))
    print(number_lst, '\n')
    lst=(sum(number_lst))

    num=num+1
    Label(aApp,text="Total purchases are:$%.2s\n" %  lst, fg = 'red',font=('times', 10, 'bold')).grid(row=0,column=1)

Iam getting the output totals of 76.0 and I think that is the 009 item counted. I can't seem to get out of the Index Error.

So it wont jump onto this part:

aApp=Tk()
aApp.geometry('650x450+185+185')
aApp.title("LOTTO")    

It just gives the Index error and stops at the>>>| and it is blinking.

76.0
 009  
Traceback (most recent call last):
  File "C:\Python33\testkill.py", line 12, in <module>
    number_lst.append(float(line[1]))
IndexError: list index out of range

I still can't get rid of this error
is it due to eof ? or end of line?

Traceback (most recent call last):
  File "C:\Python33\testkill.py", line 22, in <module>
    number_lst.append(float(line[1]))
IndexError: list index out of range

ok I will check it

The only issue I have is to change the list.
The result equals say: 54.0 but I can't seem to find what represents the amount of 54.0 I tried type and print(number_lst) but it comes back as a list or 10.0 How can I change it back to something, I can use to display, like a float that equals $54.00 varriable? and not a list?
I want to use this number in a Frame for display only reasons.
I don't need help on how to put it in the Frame.
Do I need to use .format?
Thanks

Ok I put all you gave me toghether like this and it all works fine.
Thanks snipsat

num=1
number_lst=[]

with open("C:\\write_it.txt", "r") as totals:
    for line in totals:

        print('% 04d %s' %(num, line),end = '')        
        line=line.strip().split('$')
        number_lst.append(float(line[1]))
        print(number_lst, '\n')
        print(sum(number_lst)) #54.0

        num = num+1

totals.close()

What am I missing?

This is the part that writes to the fileor appends rather:

totals = open("C:\\write_it.txt", "a")
        totals.write('$%.2f \n'  % totalc)
        totals.close()

I can try removing the

\n

This is what is appended to the file:
$10.00
$8.00
$10.00
$6.00
$10.00
$10.00
without the

\n

$10.00 $8.00 $10.00 $6.00 $10.00 $10.00

Iam also using notepad
how does it work without "C:\number.txt"mine won't work without the C:\ part
I also needed to change

number_lst = []

I needed to change to

number_lst=[]

and

line=line.strip().split('$')

No matter what I do I get: IndexError: list index out of range

The number.txt file looks like this:

'''Output-->
['$10.00', '$10.00', '$10.00', '$10.00', '$10.00', '$10.00']
[10.0, 10.0, 10.0, 10.0, 10.0, 10.0]
60.0
'''

Not sure if this will help me but....This is the file: This how the program writes the $10.00 too the file.
Iam also using notepad
how does it work without "C:\number.txt"mine won't woek without the C:\ part
and number_lst = []I needed to change to number_lst=[]
$10.00
$8.00
$10.00
$6.00
$10.00
$10.00

and this is the file:
$10.00
$8.00
$10.00
$6.00
$10.00
$10.00

this is the code I used:

totals = open('write_it.txt')
total_lst = totals.readlines()
number_lst = []
for line in total_lst:

    line=line.strip().split('$')
    number_lst.append(float(line[1]))
    print(number_lst) #[10.0, 10.0, 10.0, 10.0, 10.0, 10.0]
    print(sum(number_lst)) #60.0
totals.close()

I got this error:

Traceback (most recent call last):
  File "C:\Python33\keep2.py", line 34, in <module>
    number_lst.append(float(line[1]))
IndexError: list index out of range

also i forgot to mention each time I run the program a new amount is added to the file like this:

$10.00 
$8.00 
$10.00 
$6.00
$10.00 
$10.00 
$8.00 
$10.00 
$6.00
$10.00 
$10.00 
$8.00 
$10.00 
$6.00
$10.00

can you help me doing the same thing using the code below?
also in my version
As it is the code below wont work

print ('won't work unless I use') parentheses

As it is the code below wont work 'to the point of helping me.
It just prints out 

$10.00........or line1 line2 ..

.....

 totals= open("C:write_it.txt", "r")
    totals.readline()
    for line in totals:
    print(line)
    totals.close()

FILE:    

$10.00 
$10.00 
$10.00 
$10.00 
$10.00 
$10.00 
$10.00

ok thanks so much I will try this and get back to you.
print [float(i.split('$')[1])#########for i in lst]
I got a syntax error where I put the #######
I am not sure what the first line of code
with open('number.txt') as f:
I am using python33

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines()
['Line 1\n', 'Line 2\n', 'Line 3\n', 'Line 1\n', 'Line 2\n', 'Line 3\n']
>>>

I am not sure why this repeats line1 line2 line3 then line 1 line 2 line 3 there is 6 lines in the file.
but anyway if that does not matter...
How can I see the data such as $10.00 and not 'Line 1\n'....
How can I sum each line until it equals $60.00
Thanks for any help.

$10.00 
$10.00 
$10.00 
$10.00 
$10.00 
$10.00

Hi i have been using this site for info I dont think it is python 3 but it is helpful to me because its layout.

http://www.java2s.com/Code/Python/2D1.htm

So far this all works, almost just the way I want it to.
I am having problems with the code below
I want it to print out in the GUI window without all the {[( and extra spaces...
It prints out at the command line ok, but the GUI is not-so clear.

Thanks for any help.

######################################
    def compare ():

        s=''
        comp_a = open("C:\output.txt","r")
        s = comp_a.read()
        s = [line.split() for line in s.strip().splitlines()]   
        target = drawing2.split()  
        print('Purchased Numbers are',s)
        print('Win Number is ',target)

        def score(a, b):

         return (len(set(a[:5]) & set(b[:5])), 1 if (a[-1] == b[-1]) else 0)   
         print()

        for a in s:
            print(a, score(a, target))     
            label1 = Label(aApp,text =("Results  [                      ] ",(a, score(a,target))),fg = 'blue')        
            label1.pack(side=BOTTOM, expand=NO,  padx=3, pady=1, ipadx=1, ipady=1)   
            comp_a.close()

#################################
The program
#################################

    from tkinter import*
    import sys, random, tkinter 
    ticket_price = 2
    i=0
    g=''
    total  = 0
    comp_a=' '
    comp_b=' '
    score=0
    drawing2=''
    drawing=''
    target=''
    s=''
    sx=' '
    a=''
    b=''
    test_score = ''

    def calculatetotals():
        valid = set('12345')
        ticket_entry = tik.get()
        if ticket_entry not in valid:
            print('We permit values in {}.'.format(valid))
            label4 = Label(aApp,text = 'We permit values in 1, 2, 3, 4 or 5!',fg = 'blue').grid(row=7,column=1)
        else:
             label4 = Label(aApp,text = '                                                                        ',fg = 'blue').grid(row=7,column=1)
             mytik=int(ticket_entry)
             total = mytik*ticket_price              
             Label(aApp,text= "You purchased:$%.2f \n" %  total).grid(row=7,column=1)      
             Label(aApp,text= "\nNumber Of Tckets: %.f\n" % mytik).grid(row=6,column=1)        
             Button(aApp,text="Click Here To Draw Your Tickets!",fg='blue',bg='white'\ ...

Win Number is ['12', '25', '34', '42', '59', '-', '19']
['12', '25', '34', '42', '59', '-', '19'] (5, 1)
['02', '06', '14', '17', '39', '-', '33'] (0, 0)
This would be a jackpot and a loss I would print 'You won the jackpot'

ok This did not work or I did it wrong
if I have results like this (3,1) I am looking for a comparision
variable like (a,b)like if a=>3 and b>0 =$5.00 add $5.00 to a win variable.
in otherwords I cant manipulate (3,1) and I am asking how it is done
not with code ,though it is helpfull, just verbaly.
Thank you for you help.The output of the program is this:

Win Number is ['12', '25', '34', '42', '59', '-', '19']
['16', '34', '45', '50', '56', '-', '36'] (1, 0)
['02', '06', '14', '17', '39', '-', '33'] (0, 0)
this would be a loss. I don't know how to determine it a loss
So I can print 'You did not win this time'

Ok I have tried to fix some of the indents
So far this code should work minus the errors with tk frame stuff
it should work as far as the math.
however i still don't know how to utilize the bold code below to grab
value of a prize example

(3,0),(1,1),(2,1),(3,1)

are all winners
I don't know how to use the values though
If I print(score)

I get:

<function compare.<locals>.score at 0x00FA2C48>

or I would get an error saying I cant compare int to str
So what variable or vallue does

(3,1)

or any of the obove have?
and how can i compare them?

also I want to use only this program to learn some of the basics of python3, after it is finnished and works.
So this is why I use copy/paste and error running.
So I know it has many flaws.
Thanks for any help.

**def score(a, b):
        return (len(set(a[:5]) & set(b[:5])), 1 if(a[-1] == b[-1]) else 0)
        print()
        for a in s:
        print(a, score(a, target))
**

from tkinter import*
import sys, random, tkinter 
ticket_price = 2
i=0
g=''
total  = 0
comp_a=' '
comp_b=' '
score=0
drawing2=''
drawing=''
target=''
s=''
sx=' '
a=''
b=''
def calculatetotals():
    valid = set('12345')
    ticket_entry = tik.get()

    if ticket_entry not in valid:
        print('We permit values in {}.'.format(valid))
        label4 = Label(aApp,text = 'We permit values in 1, 2, 3, 4 or 5!',fg = 'blue').grid(row=7,column=1)
    else:
        label4 = Label(aApp,text = '                                                                        ',fg = 'blue').grid(row=7,column=1)
        mytik=int(ticket_entry)
        total = mytik*ticket_price              
        Label(aApp,text= "You purchased:$%.2f \n" %  total).grid(row=7,column=1) ...

I did this and got some data but not the comparision.
Iam still not able to read the target variable from the file and had to put it in as data
as you did.

 "target = '07 13 14 23 45  -  07'.split()"

def compare ( ) :

        comp_a= open("C:\output.txt","r")
        data=[line.split() for line in comp_a]
        target = '07 13 14 23 45  -  07'.split()
        print(data)
        print(target)
        comp_a.close()  

    def score(a, b):
      return (len(set(a[:5]) & set(b[:5])), 1 if (a[-1] == b[-1]) else 0)
      print()
      for a in data:

          print(a,  score(a,  target))

ok I understand this code I can just adapt it to read from a file.

I don't know how to adapt from the File output.txt

data = open("C:\output.txt","r")
    data= [line.split() for line in 
           .strip().splitlines()]
    target = comp_b.split()
    print(data)
    print(target)
def score(a, b):
    return (len(set(a[:5]) & set(b[:5])), 1 if (a[-1] == b[-1]) else 0)
print()
for a in data:
    print (a, score(a, target))

This is the program so far.
I know it has MANY flaws though as it is it works up to the COMPARE button.

from tkinter import*
import sys, random, tkinter 
ticket_price = 2
i=0
total  = 0
text1=0
drawing2=''
drawing=''

def calculatetotals():
    valid = set('12345')
    ticket_entry = tik.get()
    if ticket_entry not in valid:
        print('We permit values in {}.'.format(valid))
        label4 = Label(aApp,text = 'We permit values in 1, 2, 3, 4 or 5!',fg = 'blue').grid(row=7,column=1)
    else:
        label4 = Label(aApp,text = '                                                                        ',fg = 'blue').grid(row=7,column=1)
        mytik=int(ticket_entry)
        total = mytik*ticket_price              
        Label(aApp,text= "You purchased:$%.2f \n" %  total).grid(row=7,column=1)      
        Label(aApp,text= "\nNumber Of Tckets: %.f\n" % mytik).grid(row=6,column=1)        
        Button(aApp,text="Click Here To Draw Your Tickets!",fg='blue',bg='white'\
               ,command = nextx).grid(row=8,column=1)        
aApp=Tk()                                                                                          
aApp.geometry('580x170+200+270')
aApp.title("LOTTO")
tik=StringVar()
label1 = Label(aApp,text = "Welcome To Lotto.",fg = 'blue')
label1.grid(row=0,column=2)
label2=Label(aApp,text="Tickets Are ${:.2f} Each.".format(ticket_price),fg='red')
label2.grid(row=1,column=1)
label3=Label(aApp,text="How Many Would You Like?",fg='black')
label3.grid(row=2,column=1)                                                                                                   
mytik = Entry(aApp,textvariable=tik)
mytik.grid(row=2,column=2)                                                                            
button1=Button(aApp,text="Your Purchse\nClick Here",fg='blue'\
               ,command=calculatetotals)
button1.grid(row=6,column=1)

def nextx(): 

             Button(aApp,text="Click Here to see the new winning number.",fg='lightgreen',bg='black'\
                    ,command = nextz).grid(row=8,column=1)
             ticket_entry = tik.get()
             #######################################
             # outputs to Window and File("C:\output.txt","a")
             #######################################
             i = 0

             while i < int(ticket_entry):                   
               L = list(range(1,60))
               random.shuffle(L)

               g = L[:5]
               g.sort()
               f = L[5:6]                                  
               drawing = ' '.join( [' '.join (zstr(G) for G in g),' -',zstr(f[0])])
               label5=tkinter.Label(app,text = drawing).pack(padx=1,pady=2)

               comp_a = open("C:\output.txt","a")
               comp_a.write('\n')
               comp_a.write(drawing)              
               i+=1

              #########################################
              # Finnished output to window and File
               #########################################
app=tkinter.Tk()
app.geometry('600x400+75+75')
app.title(string="     NUMBERS      ")    

Button(app, text="Quit", command=app.quit).pack()
def  nextz():    
                              Button(aApp,text='Push   again to  <Quit> : To see if you match Push <Compare> In The New Winning Number Window, '\
                                     ,fg='yellow',bg='black',command = quit).grid(row=8,column=1)                                   
                              L = list(range(1,60)) ...

What I want is to compare each record at a time starting with
13 27 34 41 47 - 49 compared with 07 13 14 23 45 - 07
This would generate True or False for matching numbers. I would then evaluate the True for a prizefor each set. Example: four True would equal = $7.00 and If all numbers match It would be a jackpot of many millions.

I then would procede to the next record 22 24 45 46 51 - 15 and compare it to 07 13 14 23 45 - 07.....
I would then compare the last record 12 23 40 47 57 - 04
and compare it for a prize.
Then delete the file, or its contents.
This is what I am trying to get from this data.

So the info I need is how to compare each record list.
13 27 34 41 47 - 49
22 24 45 46 51 - 15
10 14 22 25 42 - 13
01 04 17 31 52 - 38
12 23 40 47 57 - 04

07 13 14 23 45 - 07

So so far the program looks like this

from tkinter import*
import sys, random, tkinter 
ticket_price = 2
i=0
total  = 0
text1=0
drawing2=''
drawing=''

def calculatetotals():
    valid = set('12345')
    ticket_entry = tik.get()
    if ticket_entry not in valid:
        print('We permit values in {}.'.format(valid))
        label4 = Label(aApp,text = 'We permit values in 1, 2, 3, 4 or 5!',fg = 'blue').grid(row=7,column=1)
    else:
        label4 = Label(aApp,text ...

Wow! you guys realy lost me, I have'nt realy got to this level.
So I don't understand what you did.
From what I try to understand, is that you separated the last sixth digits from the rest and compared them seprately.and returned True\False
though I can't read the prints enouph to comprehend them.

{'-', ' ', '9', '8', '1', '3', '2', '4', '7'}
{'-', ' ', '9', '8', '1', '2', '4', '7'}
{'5'}
{'3'}{'-', ' ', '9', '8', '1', '2', '5', '4', '7'}

I did this and tested it for the six number to flaw and it never did after 100's of tries. So I think this works for one set of numbers
with sixth number as powerball.

This is the file output however the program generates these as random numbers.
you can see the first number is 01 this 01 has no bearing on the sixth 01 on the first line, as far as I'v tested it.
so all the prints will come out False if you run it.

31 43 45 57 58 - 01
01 13 21 22 40 - 29

This should equal:One True for the 40 match the rest would be False:

31 40 45 57 58 - 01
01 13 21 22 40 - 31

comp= open("C:\output.txt","r") 
           s=comp.readline()     
           s.split()
           print('The draw number is', s)

           t=comp.readline()
           t.split()
           print('The win number is', t)      
           print(t[0:3] in s)
           print(t[2:5] in s)
           print(t[6:8] in s)
           print(t[8:11] in s)
           print(t[12:15] in s)

           comp.close()  
           return

I never compared the sixth numbers yet but it looks like you have above I will get to it soon ie:copy & paste :)
If you can Please test this for me and let me know if it is adequate.

ok I read the link you gave me.
It is very informative though I don't understand it all.
Example: This file
06 15 26 34 36 - 16
16 24 30 34 43 - 20

compare= open("C:\output.txt","r")
s=compare.readline()
s.split()
Output:equals this.
['06', '15', '26', '34', '36', '-', '16']
Then I did this.
t=compare.readline()
t.split()
Output:equals this.
['16', '24', '30', '34', '43', '-', '20']
Then I did this.
print(t[0:3] in s)
wich output:
False
Ok False is desired, since the last 16 is compared differently
But I dont know why it came out <False> when <16> is in <s>
Or is it I don't know.
it turns true if I place 16 say like this in the file.

06 15 16 34 36  - 26
16 24 30 34 43  - 20

`

s[2:4]equaled the first one 09
and s[4:8] equaled the second one 12
next one did'nt work, So I have no idea how to pick out the specific number. oh i got s[8:10]=33 but I guessed still dont know how.
s[10:14]= 37 got this one and the last one also s[14:16]=52
and the last one s[19:22]=' 46' oh extra space s[20:22]='46'
ok thanks alot for the little puzzle:)

s[2:4]
'09'

s[4:8]
' 12 '
ok I'm getting close I guess