woooee 814 Nearly a Posting Maven

Can't you just take the difference between price and priceW, and then multiply by rate. If you want to print out every increment, then some kind of loop is necessary, and should be in a function that you pass the prices, rate, and literal to print, since both calculations are the same.

woooee 814 Nearly a Posting Maven

You hit the Enter key without any data. You should know what the code does even if you get it from someone else. What is necessary to exit in this code?

in_str=""
    while in_str != "q":
woooee 814 Nearly a Posting Maven

for i in (hold2.split()[0:25]):
AttributeError: 'list' object has no attribute 'split'

You want to split, etc. "i", not the list "hold2".

woooee 814 Nearly a Posting Maven

I think graphics has an undraw() method, you'll have to check to be sure, but set a variable to True or False. If True, call function_1 which undraws "standing" and draws "jump" and set variable=False. If False, call function_2 and do the reverse. It would be much easier if all of figure 1 is in list_1, and all of figure 2 is in list 2. A pseudo-example:

win = GraphWin ("GraphicsWin", 900,700)

def draw_1(list_1):
    for object in list_1:
        object.draw(win)

def undraw_1(list_1):
    for object in list_1:
        object.undraw()

def stand():
    ret_list=[]
    circ = Circle(Point(200,400),30)
    ret_list.append(circ)

    line1 = Line(Point(200,430),Point(200,530))
    ret_list.append(line1)

    ## etc
    return ret_list

list_1 = stand()
for ctr in range(5):
    draw_1(list_1)
    time.sleep(1.5)
    undraw_1(list_1)
    time.sleep(1.5)
woooee 814 Nearly a Posting Maven

This question is in all of the other forums and so has probably already been answered.

imperialguy commented: This person is killing the chances of getting a solution to this problem. I don't know why he is doing it. -1
woooee 814 Nearly a Posting Maven

You can't run Tkinter apps from Idle because Idle is written in Tkinter and 2 instances of the Tkinter class confuses it. You can also clean up a lot of the redundant code.

""" instead of changeI1(), changeI2(), etc. use a list to store the buttons and
          have them all point to the same function, providing the button number.
      """    
      from functools import partial
      self.button_list = []
      for b in range(4):
         but = Button(self, text="Change I-"+str(b+1))
         but.bind("<Button-1>", partial(self, changeI, but_num=b)
         but.grid(row=b, column=4, sticky=W+E+N+S)
         self.button_list.append(but)

      """ all buttons call this function.  The button number will look up the button
          number in a dictionary
      """
      def changeI((self, event, but_num):
         ## this is an example only
         ## but ditto for button numbers 3, & 4
         change_dict={1:(("I1N", "yellow", "green"), ("I1S", "yellow", "red"),
                         ("I1W", "red", "green"), ("I1E", "red", "green")),
                      2:(("I2S", "yellow", "red"), ("I2W", "red", "green"),
                         ("I2E", "red", "green"))}

         for tag, color_1, color_2 in change_dict[but_num]:
             self.canvas.itemconfigure(tag, fill=color_1)
         self.update()
         time.sleep(1)
         for tag, color_1, color_2 in change_dict[but_num]:
             self.canvas.itemconfigure(tag, fill=color_2)

      # use a for loop to update the buttons
      else:
         self.state = 0
         self.ChangeAutoButt.configure(text="Auto On")
         for but in self.button_list:
             but.configure(state=NORMAL)

         #self.ChangeI1Butt.configure(state=NORMAL)
         #self.ChangeI2Butt.configure(state=NORMAL)
         #self.ChangeI3Butt.configure(state=NORMAL)
         #self.ChangeI4Butt.configure(state=NORMAL)
         #self.ChangeI5Butt.configure(state=NORMAL)
woooee 814 Nearly a Posting Maven

but i know how to compare and find the age i just dont know how to show the name of the person

You want to use

for key, item in a_dictionary.items():
#
# or
for key in a_dictionary:
    if a_dictionary[key] == age:
woooee 814 Nearly a Posting Maven

sys.exit() is never a good idea. In this case Tkinter's quit() is the preferred way to exit. The program runs on my Slackware system with this modification to endProgram()

def endProgram (self):
      if self.state == 0:
         self.master.quit()
      else:
         print ("state is not zero -->", self.state)
woooee 814 Nearly a Posting Maven

You do not allow for an equal condition in the commented code. Since you did not say what "wrong" is, we can only guess.

woooee 814 Nearly a Posting Maven

There is more than one way, but you could use a for() loop with step=4. We don't have the file so you will have to test and correct this yourself.

def block_generator():
        with open ('test', 'r') as lines:
            data = lines.readlines ()[5::]

            for ctr in range(0, len(data), 4):
                block = []
                for x in range(4):
                    block.append(data[ctr+x]
                print block
Gribouillis commented: I like the " with ... as lines" +13
woooee 814 Nearly a Posting Maven

First, you have to call "hanlderf()" and create the text widget. Since I don't have the file, the text inserted into the widget is different.

from tkinter import *
 
def handler(event):
    print("Clicked at", event.x, event.y)
 
class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.grid()
 
        for r in range(6):
            self.master.rowconfigure(r, weight=100)    
        #Creating custom buttons
        self.master.columnconfigure(0, weight=100)
        Button(master, text="Red",command=self.colorit).grid(row=6,column=0,sticky=E+W)
        self.master.columnconfigure(1, weight=100)
        Button(master, text="Blue").grid(row=6,column=1,sticky=E+W)
        self.master.columnconfigure(2, weight=100)
        Button(master, text="Green").grid(row=6,column=2,sticky=E+W)
        self.master.columnconfigure(3, weight=100)
        Button(master, text="Black").grid(row=6,column=3,sticky=E+W)
        self.master.columnconfigure(4, weight=100)
        Button(master, text="Open", command=self.hanlderf).grid(row=6,column=4,sticky=E+W)
 
        Frame1 = Frame(master, bg="red", width=100, height=50)
        Frame1.grid(row = 0, column = 0, rowspan = 3, columnspan = 2, sticky = W+E+N+S) 
        Frame1.bind("<Button-1>", handler)
        Label(Frame1, text='frame1').grid(row=0)
 
        Frame2 = Frame(master, bg="blue",width=100, height=50)
        Frame2.grid(row = 3, column = 0, rowspan = 3, columnspan = 2, sticky = W+E+N+S)
        Frame2.bind("<Button-1>", handler)
        Label(Frame2, text='frame2').grid(row=3)
 
        self.Frame3 = Frame(master, bg="green",width=200)
        self.Frame3.grid(row = 0, column = 2, rowspan = 6, columnspan = 3, sticky = W+E+N+S)
        self.text_in = Entry(self.Frame3,text="this is a text")
        self.text_in.grid(row = 5, column = 2)
        Label(self.Frame3, text='frame3').grid(row=0,column=2)
 
        ## call the function
        self.hanlderf()

    def hanlderf(self):
        """
        try:
            text = self.text_in.get()
            myFile=open(text) # get a file handle
            self.myText= myFile.read() # read the file to variable
            myFile.close() # close file handle
        except Exception as msg:
            print("An error has ocurred: %s" % msg)
            self.myText="An error has ocurred.!"
        """ 
        self.myTextWidget= Text(self.Frame3)
        self.myTextWidget.insert(0.0,"Change this color")
        self.myTextWidget.grid(row = 7, column = 2)
 
    def colorit(self):
        """ changes the text widget foreground color to blue when the 'red'
            button is clicked
        """
        self.myTextWidget.configure(fg='blue')
#        self.myTextWidget.tag_config(self.myText, foreground="blue")
        #text.tag_config("a", foreground="blue")
        #text.insert(contents, ("n", "a"))
        self.myTextWidget.insert(END, "\nColor changed")
        print("changing the color")
 
 
root = Tk() …
woooee 814 Nearly a Posting Maven

Since 2 loops would be required to solve this, you can also use two recursive functions. The following code compares the first number to all other numbers in the list. You would then create a top level function that would pass the original list to this function and then call itself again recursively after deleting the first number, so the second number would then be compared to all other numbers in the list, etc. Note that this function uses a copy of the list. Lists are passed by reference, meaning that the address in memory is passed, so any changes to one list affects all references to the list. When passing a list to more than one function it is a good idea to use a copy of the list.

def test_numbers(this_list, found_list):
    print "  list_in =", this_list
    
    ## if out of numbers, just return found_list
    if len(this_list) > 1:
        print "     comparing", this_list[0], this_list[1]
        if this_list[0] + this_list[1] < 0:
            found_list.append([this_list[0], this_list[1]])
        del this_list[1]
        found_list = test_numbers(this_list, found_list)

    return found_list

test = [1,6,7,-4,36,3,4]
print test_numbers(test[:], [])   ## passes a copy of the list
woooee 814 Nearly a Posting Maven
test = input("Enter numbers: ")
neg_sum(test)

I tried to convert the input into a list, however I still got errors

How did you convert it to a list? You also have to convert the numbers to integers also. It is better to ask for one number at a time and use a try/except to convert to an int, and then append to the list.

woooee 814 Nearly a Posting Maven

What, more pumpkins?
Daniweb patch site due for release on the 30th of October http://www.daniweb.com/community-center/geeks-lounge/threads/388742

The first Jack O’Lanterns were actually made from turnips. The name (Jack of the Lantern) and the turnip come from a too-long-to-tell-here Irish story about a man named Jack, who tricks the devil and is ultimately forced to wander in the night with only a glowing coal in a turnip for light.

woooee 814 Nearly a Posting Maven

You have to return the values, see http://www.penzilla.net/tutorials/python/functions/ for starters.

def fcn1(record):
    do some stuff
    write result to a new file
    return data_from_this_function
     
def fcn2(data_from_fcn1):
    do some stuff
    write result to a new file
    return data_from_this_function
     
def fcn3(data_from_fcn2):
    do some stuff
    write result to a new file
    return result
     
#___________main___________
f=open('filename','r'
fread=f.readlines()
for f in fread
    res1=fcn1(f)
    res2=fcn2(res1)
    res=fcn3(res2) 

##------- you can run the following
def func_1(list_in):
    list_in.append("added by func_1")
    return list_in

def func_2(list_in):
    for ctr in range(len(list_in)):
        if list_in[ctr] == "added by func_1":
            list_in[ctr]=list_in[ctr].replace("func_1", "func_2")
    return list_in

def func_3(list_in):
    list_in.append("ADDED by func_3")
    return list_in


res_1=func_1([])
print res_1
res_2=func_2(res_1)
print res_2
res=func_3(res_2) 
print res
woooee 814 Nearly a Posting Maven

Do you want to do this in the console, as the post above, or did you intend on using a GUI. Some sample input and output would also help.

woooee 814 Nearly a Posting Maven

My biggest problem is figuring out where to start. Even the pseudo code doesn't help me very much

PA 5 Pseudocode
0. Read file, strip lines, split lines on commas, create list of lists or tuples, etc.
1. Process the list printing the state name if its length is >=11

Either you are stupid and aren't able to Google for these simple tasks, or you are calling us stupid. Please read this thread http://www.daniweb.com/software-development/computer-science/threads/573

woooee 814 Nearly a Posting Maven

I'm just a beginner trying to learn, but since the problem says that its supposed to check any two numbers in a list that adds up to a negative not just consecutive numbers, wouldn't it work if a for loop was added?

Yes and would be better as loops are almost always better than recursion IMHO, but the problem states that the program must use recursion.

woooee 814 Nearly a Posting Maven

I you want to use Tkinter then you should also install the Pmw extension. It makes things much easier IMHO, and is a collection of Python/Tkinter files that extend Tkinter. That means it is easy to install as it is installed by copying to anywhere in your PYTHONPATH (sys.path). This is how it would be done with Pmw. Click on any item to print that item to the console.

import Tkinter
import Pmw

class PMWListBox :
   def __init__( self, list_in, min_width=300, min_height=300 ) :
      self.top = Tkinter.Tk()
      self.top.geometry( "300x300+10+10" )
      self.top.minsize( min_width, min_height )
      self.top.option_add('*Font', 'Fixed 14')
      
      Pmw.initialise( fontScheme='default')

      #---  exit button must be first----------------------
      exit = Tkinter.Button(self.top, text='EXIT',
             command=self.top.quit, bg='lightblue', fg='yellow' )
      exit.pack(fill="x", expand=1, side="bottom")

      #----------------------------------------------------------------
      self.sl_box = Pmw.ScrolledListBox( self.top, listbox_selectmode="SINGLE", \
               items=(list_in), selectioncommand=self.getit_2 )
      self.sl_box.pack(fill="both", expand=1, padx=5, pady=5, side="top" )
  
      #----------------------------------------------------------------
      self.top.mainloop()

   def getit_2(self):
#      print "getvalue", self.sl_box.getvalue()
      print "getcurselection", self.sl_box.getcurselection()

##===================================================================
if __name__ == "__main__" :
   list_items = [ "First List Entry", "Second List Entry", \
                  "Third List Entry", \
                  "Fourth List Entry -- W I D E -- W  I  D  E", \
                  "Fifth List Entry", "Sixth Entry", "Seventh Entry", \
                  "Eighth Entry", "Ninth Entry", "Tenth Entry", \
                  "Entry # 11 Test", "Test for 12th Lit", \
                  "Thirteen", "Fourteen", "Fifteen" ]
   PM = PMWListBox( list_items )
Gribouillis commented: great and stylish +13
woooee 814 Nearly a Posting Maven

Write a program that creates a linked list of bunny objects

This is just a list of objects, because to create a linked list you have to link one to the other in some way but the link was not given (and I did not read it carefully so may have missed it). Please read and observe the Python Style Guide. It makes someone else's code that much easier to read and increases your chances of getting some help. There are other ways to do this, like keeping track of the total males and females to create an equal number, so experiment if you wish. This is a subset of what you want to do, and is not tested.

import random

class Bunny:
 
    def __init__(self, female, male, fur, tot_males, tot_females):
        ## all of these are filled in by the functions
        self.gender = self.bunny_gender(tot_males, tot_females)
        self.name = self.bunny_name(female, male)
        self.fur = random.choice(fur)
        self.age = random.choice(range(0,11))
 
        print "Created", self.name, self.gender, self.fur, self.age
   
    def bunny_name(self, female, male):
        if 'Male' == self.gender:
            return random.choice(male)
        return random.choice(female)
 
    def bunny_gender(self, tot_males, tot_females):
        choice = random.choice([0,1])
        if choice:
            if tot_males < 5:
                return 'Male'
            else:
                return 'Female'
        elif tot_females < 5:
            return 'Female'
        return 'Male'
        
female_names_list = \
"Fufu.Ophelia.Oryctolagus.puddles.Nidoran.Cherry.Holly.Stacy.Lucy.Rona".split(".")
male_names_list = \
"Bill.Fred.Tex..Max.Fluffy.Thumper.Harvey.Romeo.Chocolate.Pebbles".split(".")

#fur = open("BunnyFur.txt").read().strip('\n').split(".")
fur = ["white", "brown", "spotted", "black"]

bunny_class_instances=[]
total_males=0
total_females=0
for b in range(10):
    BY = Bunny(female_names_list, male_names_list, fur, total_males, total_females)
    if 'Male' == BY.gender:
        total_males += 1
        male_names_list.remove(BY.name)
    else:
        total_females += 1
        female_names_list.remove(BY.name)
    bunny_class_instances.append(BY)


for instance in bunny_class_instances: …
woooee 814 Nearly a Posting Maven

[13, 9, 15, -10, 11] would return True, because 9 + -10 is a negative number

You have to compare each number to all of the other numbers, not just side-by-side pairs. I would suggest that you sort the list in reverse order so all negative numbers are at the end, and send to a function to compare the first element with all others and return a list of "True". You can then remove the number tested and call the function recursively,

woooee 814 Nearly a Posting Maven

Normally you would use line.strip().split() and the length of the resulting list.

woooee 814 Nearly a Posting Maven

I've overlooked the obvious. It should be

for key, item in my_dict.items():

Hopefully it works now.

woooee 814 Nearly a Posting Maven

Vegaseats' code did not work here because you are already reading the file with
"for line in myFile".
Since you already have a individual line, it is better to use that line than read the file all over again.

woooee 814 Nearly a Posting Maven

A complete error message is like the following and greatly increases your chances of receiving some help.

my_dict = {1:"1"}
n = open('file.csv',"w")
for item in my_dict.items():
		f.write(item)
f.close()

"""
Traceback (most recent call last):
  File "./test_1.py", line 94, in <module>
    f.write(item)
NameError: name 'f' is not defined
"""
woooee 814 Nearly a Posting Maven

You should be passing line to the function.

def percount(line):
    periods = 0
    for char in line:
        if char == '.':
            periods +=1
    return periods

for line in myFile:
...
##    for char in line:
    p = percount(line)
    total_periods += p

Also, in the real world
if line == ('\n'):
is rarely used as there may a space in the line as well. You can use instead:

if len(line.strip()):
bigredaltoid commented: Wooee has been an immense amount of help to this new Python user! +1
woooee 814 Nearly a Posting Maven

Please see line 3 in the first/top program in that post. If you had included the entire error message in the first place it would have shown that that was the error line and saved everyone some time.

woooee 814 Nearly a Posting Maven

f is never declared and so is not a character buffer.

woooee 814 Nearly a Posting Maven

.txt files do not support bold or underlining. To do that you must use a mark-up file like postscript, html, or XML. But each one uses a different method. If you are viewing the file in a text or word processor you must use the markup style that it expects, unless it will import other styles. Copy this to a file and open it with a web browser to see an example of how to output in html.

<html>
<head>
<title> This is the title.
</title>
</head>
<body>
<b>Bold</b>
<u>underline</u>
</body>
</html>

If you want you can use a tool like html2ps to convert this to postscript to see how postscript does this (postscript just inserts code to draw a solid line at the distance under the word).

woooee 814 Nearly a Posting Maven

Adding print statements will tell you what is going on.

for line in in_file:
 print "line =", line
 number = line.split()
 print "number =". number
 for col in number[0]:
  print "comparing", col, number[3]
  if col == number[3]:
   print number[0], number[1], number[2], number[4]
woooee 814 Nearly a Posting Maven

Everything should be under the while loop.

number = int(raw_input("Please enter a number: "))
largest = number
while (number>0):
    number = int(raw_input("Please enter anohter number: "))

    if (largest>number):     ## this will give the smallest
         number = largest
    ##if (number<0):    not necessary as the while loop takes care of this
print "The largest number was: ",number
woooee 814 Nearly a Posting Maven

Recursion = a function that calls itself and is along the lines of

def recursion_funct(list_in):
    print "list is now", list_in
    if len(list_in) > 1:
        recursion_funct(list_in[1:])
    else:
        return    ## out of entries in the list

test_list=[13, 9, 15, -10, 11]
recursion_funct(test_list)

First figure how to use a function that calls itself (maybe tests the first entry against all negative numbers and then return a list from each successive call, but then what do you do if there is a positive number after a negative number). You'll have to figure that out before you can start coding.

woooee 814 Nearly a Posting Maven

First search for "Python anagram" at Daniweb using the search box at the top of the page. That will give you several techniques for using a list of words and will not require us to answer the same question over and over.

## this will always be true on the first pass
        if is_anagram(word, word_list[0]):   

  
        # these lines do nothing as index1 is never used
           index1 +=1
 
        else:
            index1 += 1
woooee 814 Nearly a Posting Maven

Your original code would look something like this, but take note of the try/except as that is usual way of getting input.

number=0
while number>=0 and number<=100:
    ## will only add to total if the input from the previous loop is 0 <= number <= 100
    total+=abs(number)     ## adds number==zero on the first pass
    number=float(input("Enter a number: "))
woooee 814 Nearly a Posting Maven
myFile = open("inn.txt", "r")
 
for line in myFile:
    lines +=1
 
    if line == ('\n'):
        blanklines +=1
 
for char in myFile:

When you get to "for char in myFile" you are already at the end of the file (because "for line in myFile" went through the entire file) so there is no data read. It should be:

myFile = open("inn.txt", "r")
 
for line in myFile:
    lines +=1
 
    if line == ('\n'):
        blanklines +=1
 
    for char in line: 
        if char == period:             #3
        if char not in [" ", "\n"]:    #4 do both in the same loop
    #etc...#5 will also be under the "for line in myFile" loop and use "line".

Python does have a count() function but I assume that you are supposed to code this for yourself.

woooee 814 Nearly a Posting Maven

8 is a leap year. 104 is also a leap year but your code will not catch it. In pseudocode:
1. Is the year evenly divisible by 4
2. Is the year evenly divisible by 100. If divisible by 4 and not by 100 it is not a new century and is a leap year.
3. If year is evenly divisible by 100 it is a new century. Centuries are only leap years if they are divisible by 400, so to be a leap century a year has to be evenly divisible by 4, 100, and 400. 2000 is a leap year; 1900, 1800, and 1700 are not leap years.

Please hit the [code] button for pasting code as indentation is significant.

woooee 814 Nearly a Posting Maven

In that case it is pretty simple. You can just the format string % operator, see 5.6.2. String Formatting Operations. An example, and it looks like you've already padded by one space so I don't.

lens_list = [5, 3, 10]
data_list = [ [123, 17, 12345], [12, 18, 123456789], [2345, 1, 2]]

format_str = "Card"
for length in lens_list:
    format_str += "%"+str(length)+"d"
print format_str ## for your info

for data in data_list:
    print format_str % (data[0], data[1], data[2])
woooee 814 Nearly a Posting Maven

You would first have to store the rows so you can find the largest number in each column. Post the code for that and we would then have enough info to be able to help with the final formatting.

woooee 814 Nearly a Posting Maven

Please mark the thread as solved to save others the time it takes to read through this post only to realize it is solved. I think the "solved" button is just above the box where replies are posted..

woooee 814 Nearly a Posting Maven

You would use readlines() to read the file into a list, process the list however many times you want, and then write the list to another file.

def f1(data_list):
    """ add one to even numbered elements
    """
    for ctr in range(1, len(data_list), 2):
        data_list[ctr] = int(data_list[ctr].strip()) + 1
    return data_list

def f2(data_list):
    """ subtract one from odd numbered elements
    """
    for ctr in range(0, len(data_list), 2):
        data_list[ctr] = int(data_list[ctr].strip()) - 1
    return data_list

"""
def f3(result2):
    do something 
    return res3
"""

#test_data = open(filename1, 'r').readlines()
## simulate open and readlines
test_data = [ '1\n', '2\n', '3\n', '4\n', '5\n', '6\n']
test_data = f1(test_data)
print "after f1", test_data
test_data = f2(test_data)
print "after f2", test_data

## write file here after all processing has been done
woooee 814 Nearly a Posting Maven

A basic principle is that you have bytes of data. In your case you want to modify and store the bytes several times. It does not matter how you store them. You can create files to store them, as in this program, or you can store them in a list or SQLite database and pass the container around. Also, in program 2, you open and read a file each time through the loop. Read it once only.

#program 2
f2=open('filename1', 'r')  # open file created in newfile in program 1
newfile=('file_name2', 'w')

f3_data=open(filename3. 'r').readlines()

for lines in f2.readlines():
#	f3=open('filename3', 'r')
	for data in f3_data:
		if lines.split('\t')[0] in datat:
			write to new_file	
#	f3.close()    ## open + readlines on one line does this for you

f2.close()
new_file.close()
woooee 814 Nearly a Posting Maven

If you use a loop then you should also use "update_idletasks" or no updates will happen until the loop exits. Note that this code is for Python2.x

from Tkinter import *
import time
 
class MyGui():
   #state = 1 ---> label is green
   #state = 0 ---> label is red
   #state = 0
 
   def __init__(self, master=None):    # 1
#      Frame.__init__(self)    # 2
      self.master=master
      self.master.title( "Traffic Light Control EGR 101")
      self.master.grid()
      self.master.rowconfigure(0, weight=1)  # 3
      self.master.columnconfigure(0, weight=1)  # 4
      
      self.canvas = Canvas(self.master, width=100, height=100)
      self.canvas.grid(row=0, rowspan=3, column=0)
 
      self.canvas.create_oval(10,10,90,90, width=2, tags="topLight")    # 5
      self.state=0
      self.greenButt = Button(self.master, text="Green", command=self.fillGreen)  # 6
      self.greenButt.grid(row=0, column = 1, sticky=W+E+N+S)   # 7
 
      self.redButt = Button(self.master, text="Red", command=self.fillRed)
      self.redButt.grid(row=1, column=1, sticky=W+E+N+S)
 
      self.autoButt = Button(self.master, text="Auto", command=self.fillAuto)
      self.autoButt.grid(row=2, column=1, sticky=W+E+N+S)
 
      self.label1 = Label(self.master, text="Hello", font=16)
      self.label1.grid(row=3, column=1)
 
   def fillGreen(self):
      self.canvas.itemconfigure("topLight", fill="green")   # 8
      self.label_color()
 
   def fillRed(self):
      self.canvas.itemconfigure("topLight", fill="red")
      self.label_color()
 
   def fillAuto(self):
      for ctr in range(10):     ## cycle 10 times and quit
          print ctr
          if self.state:
             self.fillGreen()
          else:
             self.fillRed()
          self.master.update_idletasks()
          self.state=not self.state
          self.label_color()
          time.sleep(1)
 
   def label_color(self):
      if self.state == 1:
         self.state = 0
         self.label1.configure(fg="red")  # 9
      else:
         self.state = 1
         self.label1.configure(fg="green")
 
root=Tk()
MG=MyGui(root)
root.mainloop()
woooee 814 Nearly a Posting Maven

First find the summing numbers. You have no "num" because you have no sums. For the number 8 for example, 4+4 or 6+2 will not work, so it has to be 5+3 or 7+1. To test the number 8, you would have to test 1, 2, 3, 4, 5, 6, 7 (1+7, 2+6, 3+5, 4+4), and that would be the case with most even numbers, so you would test 1 & number-1, 2 and number-2, etc. I would suggest that you first create a set of prime numbers up to whatever point you are supposed to go and then lookup the number in the set of primes, instead of testing the same numbers for prime every time through.

woooee 814 Nearly a Posting Maven

You did not say anything about also finding "align=top". To do that, check if the string starts with a quotation mark, in which case the first function works fine. If no quotation mark is found, then split on white space. You will have to code some of this yourself instead of giving us one task after another until the program is written for you. This forum is for helping those with code, so if you post code then we will help.

woooee 814 Nearly a Posting Maven

For the example line you gave

def find_attribute_value(html_tag, att):
    ## is att in html?
    if att in html_tag:
        ## find the location of att
        idx = html_tag.find(att)
        ##split on the quotation marks for everything after att
        first_split = html_tag[idx:].split('"')
        print first_split[1]
    else:
        print "attribute %s Not Found" % (att)

def find_attribute_value2(html_tag, att):
    """ this is the way you were trying to do it
    """
    first_split = html_tag.split()
    for x in first_split:
        if att in x:
            second_split = x.split("=")
            fname=second_split[1].replace('"', "")
            print fname
            return

test_line = find_attribute_value('<img align=top src="photos/horton.JPG" alt="Image of StG instructor (Diane Horton)">', "src")

test_line = find_attribute_value2('<img align=top src="photos/horton.JPG" alt="Image of StG instructor (Diane Horton)">', "src")

and note that this will only find the first instance of "att". And you can split on "=" as a second split(), if you know there is always space after the file name.

Hikki_Passion commented: YOU MADE IT WORK! :O Genious! +1
woooee 814 Nearly a Posting Maven

if '123' not in os.uname()[1]:

woooee 814 Nearly a Posting Maven

geting a error after my : in my if statement about the dog

That tells us nothing.

def calculate_tax():
    taxable_income=int(input('Enter your income here'))
    taxable_income=credits(taxable_income)
    tax=0
    if taxable_income<=10000:
        tax=.05*taxable_income
    elif taxable_income<=25000:
        tax =(0.1*10000)+(0.1*(taxable_income-10000))
    elif taxable_income<=35000:
    	tax =(0.15*10000)+(0.1*(taxable_income-10000))
    else:
        tax =(0.25*10000)+ (0.1*(taxable_income-10000)
                            )
def credits(taxable_income):
    dog=int(input("enter number of dogs you have")
    if dog>=1:
        taxable_income=taxable_income-300
        print ("300 has been deducted away from your total")
    else:
        print("no deduction")
    cat=int(input("enter number of dogs")
    if cat >=1:
        taxable_income=taxable_income-200
        print("200 has been deducted away from your total")
    else:
        print("no dections have been taking away")      
 
##        print('Your tax due is $',format(tax,',.2f'))

    return taxable_income

calculate_tax()
woooee 814 Nearly a Posting Maven

You can also do it this way.

taxable_income=""
while not taxable_income.isdigit():
    print("Enter")
    taxable_income=input('Enter your income here (whole dollars only) ')
taxable_income = int(taxable_income)

tax=0
if taxable_income<=10000:
     tax=.05*taxable_income
elif taxable_income<=25000:
     tax = 0.1*taxable_income
elif taxable_income<=35000:
     tax = 0.15*taxable_income
else:
     tax = 0.25*taxable_income
print(tax)
#
#
tax_rates = ( (35000, 0.15), (25000, 0.10), (10000, 0.05) )
tax = 0.25*taxable_income  ## default = largest rate
for rate_tuple in tax_rates:
    if taxable_income <= rate_tuple[0]:
        tax = taxable_income*rate_tuple[1]
print(tax)
woooee 814 Nearly a Posting Maven

1. I am having an issue giving values to each card, ex assinging FaceCards=10 Aces=11 and cards 2-10 to their number values.

What is in the card deck? Are they 1-52, in which case every group of 13 would be a suit, so 1=2 Clubs, 14=2 Diamonds, etc. or are they something like "2C", "2D"? Post the code you have so far.

2) I am having an issue getting the game going, for instance, once the players are given out I don't know how i could code it so the player has the option of choosing the card from the discard pile and deck...and if they choose either one...how i would be able to add that string to their hand and subtract a card they don't want

I would assume that you would ask for one of 3 options
1. discard pile
2. deck
3. no additional cards
and then a random choice if 1 or 2.

how i would be able to add that string to their hand and subtract a card they don't want

No idea as we don't know how you store the "hand".

woooee 814 Nearly a Posting Maven

Using == is always dicey. Add a print statement to see what happens, and instead of ==190, use > 189.

for i in range (100000):
        print x, y
        # move the circle 
        circle.move(dx, dy)
        x = x + dx
        y = y + dy
        # when x reaches 190, reverse the direction of movement in
        # the x direction
        if x > 189:
            dx = -1*dx
#        else:
#            dx = dx   ## Huh...this statement does nothing