woooee 814 Nearly a Posting Maven

The easiest to understand is to Use a function

def get_one_salary(ctr):
    while True:  ##infinite loop
        salary=raw_input("enter the salary #%d: " % (ctr+1))
        try:
            salary = float(salary)
            return salary
        except ValueError:
            print "could you please enter the correct salary? "

n = int(raw_input("enter the number of employee: "))
salary = []
for ctr in xrange(n):
    input_value = get_one_salary(ctr)
    salary.append(input_value)
print salary
woooee 814 Nearly a Posting Maven

That would be just a simple
1. compare the first number with the remaining (2 in this case)
2. swap the first and second number and do again

You would continue swapping if there were more digits. You have not included enough actual code to really comment on so it is difficult to move on from where your code starts. Note that the input "self.word" is not being used anywhere so whatever result you get it will not include the digits from the input. Also note that 123 and 321 are sometimes condsidered the same combination. Present a simple example in a few lines where you combine and swap and perhaps we can help more.

woooee 814 Nearly a Posting Maven

"Better" is in the eye of the beholder. The first rule is that the program does what it is supposed to.

def in_order(t):
    for ctr in range(1, len(t)):
        if t[ctr-1] > t[ctr]:
            return False
    return True

for t in ([1,2,2], ['b','a'], [3, 1, 5, 2, 4],
          ['d', 'a', 'c', 'b'], ['a', 'b', 'b', 'd', 'e', 'e', 'f', 'g']):
    print t, in_order(t)
woooee 814 Nearly a Posting Maven

Once again, lists are mutable (passed by reference) so global is unnecessary. Another example :

def print_row():
   print rowA

rowA = ['*', '*', '*', '*', '*', '*', '*', '*']
print_row()

for ctr in [1, 3, 5]:
   rowA[ctr] = "X"
print_row()
woooee 814 Nearly a Posting Maven

Lists are mutable, which means they can be used without global. The problem is possibly in the code you use to update the list; it truncates the list also. Run the code example below. You are asking questions that are in most tutorials so you should start with a tutorial instead of asking us to answer questions that every beginner should know. A place to start = tutorial on lists Click Here Python Wiki list of tutorials Click Here

rowA = ['*', '*', '*', '*', '*', '*', '*', '*']
seat=5
rowA[0:int(seat)] = ['X']  ## copies up to "seat" only
print "update 1", rowA 
#
# instead
rowA[0]="Y"
rowA[2]="X"
print "update 2", rowA
#
for ctr in range(0, 3):
    rowA[ctr] = "Z"
print "update 3", rowA
woooee 814 Nearly a Posting Maven

If finds "didn't" in the following test. Also, you do not strip the newline character(s) after reading the files, and because you use "in" instead of creating a dictionary or set of individual words and comparing word with word; the word "and" will be found, i.e. is in, when compared to the word "sandy"

#fullwords = open("Enwords.txt").read()
#contrwords = open("Encontract.txt").read()
fullwords=['accept', 'actually', 'again', 'ago', 'all', 'allow', 'already', 'always', 'and', 'another', 'apply', 'are', 'around', 'author', 'bang', 'be', 'believe', 'bible', 'big', 'billion', 'but', "can't", 'cannot', 'cause', 'caused', 'could', 'creation', 'description', 'do', 'does', "doesn't", 'exist', 'explained', 'for', 'genesis', 'god', 'have', 'he', 'here', 'i', 'if', 'in', 'incorrect', 'is', 'it', 'its', 'laws', 'likely', 'literally', 'malarky', 'mean', 'meant', 'most', 'no', 'not', 'of', 'okay', 'old', 'only', 'period', 'physics', 'put', 'responsible', 'say', 'simply', 'so', 'taken', 'that', 'the', 'then', 'there', 'think', 'this', 'those', 'thought', 'to', 'true', 'universe', 'way', 'what', 'which', 'wrong', 'years', 'you']
contrwords=["can't", "didn't", "doesn't"]
wordlist = []
nonwordlist = []
failedwords = []
string4 = "I have already explained this I thought. Okay here it is again. I beleive that the laws of physics apply to the universe and always have. Those laws do not allow the universe to be only 6000 years old. So the only way in which God could be responsible for the creation of the universe is if the bible is incorrect in its description of creation. That doesn't mean there is no God, but only that if he does exist, he is not the author of the bible if he meant …
woooee 814 Nearly a Posting Maven

Use a while loop to generate random numbers until a valid number occurs:
- Ships can't overlap --> keep track of the occupied squares in a list
- Ships must be within the gamegrid --> you can supply a range for rows and a range for columns
- Ships must be going down or across --> randomly choose 0 (across) or 1 (down) and then get a random number for column start or row start.

woooee 814 Nearly a Posting Maven

I can't tell what your code looks like because it is not indented.

doubler is now f(2) = return g so that is removed and the value from doubler(5) gets assigned to y that is why you get the x*y value and not "function g at blah blah" which is what the return g would print. Add some print statements

def f(x):
    print " f entered", x
    def g(y):
        print "g executed", y
        return x * y
     return g

doubler = f(2)
print doubler(5)


## if you want to look at it like this: doubler as f(2) =
x = 2
def g(y):
    return x * y
woooee 814 Nearly a Posting Maven

Take a look at the first code example Click Here especially how text is assigned so it appears on the button.

woooee 814 Nearly a Posting Maven

The "in" operater is used to look up a key in a dictionary --> dictionary tutorial http://www.greenteapress.com/thinkpython/html/thinkpython012.html Note rrashkin's advice above and store each item in a string or as an element of a sub-list so you can access them individually as (s)he has done. You should not post real phone numbers or e-mail addresses on a public forum.

key = input('Enter a contact information here: ')
if key in ab:
    print (ab[key])
else:
    print("name not found")
woooee 814 Nearly a Posting Maven

In order to save volunteers here from wasting time, this thread has been cross-posted on all of the other forums groups, Active State, python-list, python-forum, devshed, dreamincode, and maybe others, so decide for yourself if you want to spend any time on this or not.

woooee 814 Nearly a Posting Maven

For starters, you have declared names to be a tuple containing one list so you would access it with
e=names[i][0]. But anyway, your code cleaned up a bit.

names=['Paul','Tim','Fred']
for nm in names:
    print nm

while True:  ## infinite loop until break is called
    a = raw_input("Choose name to be deleted:\n")
    if a in names:
        names.remove(a)
        print "name deleted"
        break
    else:
        print "No such name!Please Re-enter!"
woooee 814 Nearly a Posting Maven

Hi Guys,

Please be gentle with me as im a complete n00b. My favorite language is actually Java which im learning at Uni at the moment. However to throw a spanner in the works they have switched us over to Python, as well as learning Java. My mind has been completely boggled. I just need to understand this for the moment and Im hoping someone out there will be kind enough to help me. I have created a list with names in, and i want to delete what ever name i wish to do so. So i have put a for loop in there. Now I can delete any name WITHOUT the if-statement in there but when i put if statements in there so set either condition to be true or false it doesnt do what i want it to. here is my code:

Any ideas? Thanks :-)

   names=(['Paul','Tim','Fred'])
   def main():
       for i in range(len(names)):
       e=names[i]
           print names
           print
           a = raw_input("Choose name to be deleted:\n")
       if(a==e)
           names.remove(a)
           print "name deleted"
       if(a!=e):
           print "No such name!Please Re-enter!"
woooee 814 Nearly a Posting Maven

You define text_list to point to the same block of memory as final.

final = text_list

If you want want a copy, use copy or deepcopy

In line 107 you append final to decode_list multiple times. Break the program down into small functions that you can test individually, as fixing one error will probably just lead to many more that you can not find because you can not test each group of code the way it is now. Like Tony, 157 lines of code is more than I care to wade through so post back if there are any other problems that you can not fix.

 decode_list.append(''.join( final ))
woooee 814 Nearly a Posting Maven

That is because "! =" does not equal "!=" (original code copied for reference).

    #-------------------------------------------------------------------------------
    # Name:        module1
    # Purpose:
    #
    # Author:      User
    #
    # Created:     18/12/2012
    # Copyright:   (c) User 2012
    # Licence:     <your licence>
    #-------------------------------------------------------------------------------
    #tictactoe board

    import random

    board = [0,1,2,
             3,4,5,
             6,7,8]

    def game():
        print (board[0],'|',board[1],'|',board[2])
        print ('----------')
        print (board[3],'|',board[4],'|',board[5])
        print ('----------')
        print (board[6],'|',board[7],'|',board[8])

    def check(char, spot1, spot2, spot3):
        if board[spot1] == char and board[spot2] == char and board[spot3] == char:
            return True
    def checkAll (char):
        if check (char, 0, 1, 2):
            return True
        if check (char, 1, 4, 7):
            return True
        if check (char, 2, 5, 8):
            return True

        if check (char, 6, 7, 8):
            return True
        if check (char, 3, 4, 5):
            return True
        if check (char, 0, 1, 2):
            return True

        if check (char, 2, 4, 6):
            return True
        if check (char, 0, 4, 8):
            return True
    while True:
        p1 = input("Player 1, where do you want to place your marker?")
        p1 = int(p1)
        if str(board[p1]) ! = 'x' and str(board[p1]) ! = 'o':
            board[p1] = 'x'

    if checkAll('x') == True:
                print "Player 1 wins!"
                break
            break

    while True:
            p2 = input("Player 2, where would you like to place your marker?")
            p2 = int(p2)
            if str(board[p2]) ! = 'x' and str(board[p2]) ! = 'o':
                str(board[p2]) = 'o'

                if checkAll('o') == True:
                    print "Player 2 wins!"
                    break
            break

I made some additional changes to help you out and reduced the code in checkAll() by using a list, but the program …

woooee 814 Nearly a Posting Maven

You have made the classic mistake of including even numbers = testing twice as many numbers. Start out with i=3 and add two on each pass.

woooee 814 Nearly a Posting Maven

For starters, you can use a loop

import os

for path in [["x"], 
             ["x", "y"], 
             ["x", "y", "z"]]:
    pathname = "pathname"
    for next_path in path:
        pathname = os.path.join(pathname, next_path)
    print pathname
woooee 814 Nearly a Posting Maven

And this page says to return "break" which seems to work.

class TestSearch():
    def __init__(self):
        # Keyword Search box (user inputs keywords)
        root = Tk()
        Label(root, text="Search box: Enter keywords and press 'Enter'").pack()
        self.search_box=Text(root, height=1,width=48, padx=5,wrap='word',
                        font=('helvetica','12','bold'))
        self.search_box.bind('<Return>', self.handle_event)
        self.search_box.pack(fill='x', expand='yes',pady=2)
        self.search_box.focus_set()

        root.mainloop() 

    # Keywords Search event handler.
    def handle_event(self, event):
            search_term = self.search_box.get(1.0, END) 
            search_term = search_term.strip()
            print "adjusted", search_term
            return "break"

TS=TestSearch()
woooee 814 Nearly a Posting Maven

So we are spending our time on simple toggles huh. This uses a list so the function has access to the previous setting. I was too lazy to create a class with an instance variable.

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

def toggle():
    index_dict={"True": "False", "False": "True"}
    index[0] = index_dict[index[0]]
    t_btn['text'] = index[0]

root = tk.Tk()
index=["True"]
t_btn = tk.Button(text=index[0], width=12, command=toggle)
t_btn.pack(pady=5)

root.mainloop()
woooee 814 Nearly a Posting Maven

Take check() out from under NAC()--capture the return from a function

def check(player):
    if player == Grid[0][0] == Grid[0][1] == Grid[0][2]:
        print("%s wins!", (player))
        return True

Please read the Python Style Guide to make your code readable. Functions and variable names are lower case with underscores.

You have redundant code in the if statements

if YourGo == '7':
    Grid[0][0] = 'X'
elif YourGo == '8':
    Grid[0][1] = 'X' #Player one's turn

DisplayGrid()
check()

Also, you can map the squares to the numbers and use a for loop or simpify like this

if YourGo == '7':
    Grid[0][0] = 'X'
elif YourGo == '8':
    Grid[0][1] = 'X'
elif YourGo == '9':
    Grid[0][2] = 'X'

#------------------------------------
# replace with
this_row ['7', '8', '9']:
if YourGo in this_row:
    row = 0
    col = this_row.index(YourGo)

Grid[row][col] = 'X'

Finally, turn the above into a function and send the player to it so you don't test separately for X and O, i.e. the same code twice.

aVar++ commented: Helped me alot! +0
woooee 814 Nearly a Posting Maven

To be complete, a solution that iterates over the tuple instead of using if statements, and can accomodate any length of numbers input.

def biggest(*nums_in):
    ret_num = nums_in[0]
    for num in nums_in:
        if num > ret_num:
            ret_num = num
    return ret_num

print biggest(3, 6, 7)
print biggest(6, 5, 3, 8, 2)
print biggest(9, 3, 6)
print biggest(3, 3, 10)
print biggest(11, 3, 11)
woooee 814 Nearly a Posting Maven

Also, you read the file twice. If you want to use your existing code, use a set or dictionary for remove_index instead of a list, as the time is taken up by sequential lookups in "if count in remove_index:". Or use instead

recs_to_write=0

with open('input.txt') as infile:
    for line in infile:
        if line.startswith('BEUSLO') and target in line:
            recs_to_write=3
        if recs_to_write:
            output_file.write(line)
            recs_to_write -= 1
Gribouillis commented: nice +13
woooee 814 Nearly a Posting Maven

You should first test that what you want is there.

for cell in row:
    tmp = ('%VAR_' + headerRow[i] + '%')
    if tmp in line:
        line = line.replace(tmp, cell) # string.replace(old, new)
        print "replaced line =", line
    else:
        print tmp, "not found"
woooee 814 Nearly a Posting Maven

bh1=Radiobutton(tophelicase,text='1',variable=position,value=1,bg="green",command=tophelicase.destroy).pack()

Print bh1 to see what it contains and you should see that there is no reason to store the return from pack(), i.e. just use

   Radiobutton(tophelicase,text='1',variable=position,value=1,bg="green",
               command=fhelicase).pack()
woooee 814 Nearly a Posting Maven

I'm guessing the problem is the redundant calls to getX() and getY(). You do the exact same things 10 times for each boat drawn. That means 120 calls for the 12 boats. Move the call outside the for loops and store the values in variables. Also, the relationship between the "b" variables is constant so you only need one, i.e. instead of b2 you can use b1-12. And similar for the "s" variables. I originally though that perhaps you were supposed to use clone and move, but that wouldn't save anything and may even consume more computer resources.

woooee 814 Nearly a Posting Maven

First, use a dictionary or list of lists to hold the question and answers instead of 100 if statements. I assume you don't know about dictionaries yet so this uses a list of lists.

words = [['ano', 'um'], ['ima', 'now'], ['eego', 'english']]
random.shuffle(words)
for this_question, this_answer in words:
    print (this_question)
    translation = input('Enter the translation: ')
    if translation == this_answer:
        print('Correct!')
    else:
        print('Incorrect.')
        print('The correct answer is: '+this_answer)

    print("-"*30)

To answer your original question, learn to use print statements for simple debugging

print("comparing", words, "with ano =", translation)
if words == 'ano' and translation == 'um':
woooee 814 Nearly a Posting Maven

As Tony said, use a list. This can be run as is as a test.

def selection(number, list_colours, choices):
    while True:
        print("\nValid choices are %s" % (", ".join(list_colours)))
        colour = input("Please enter your %s valid colour: " % (number))

        if (colour in list_colours) and (colour not in choices):
            list_colours.remove(colour)
            return colour, list_colours

        else:
            if colour not in list_colours:
                print("That is not a valid colour")
            if colour in choices:
                print("You have already chosen that colour")
            ## always prints
            print("Please make your selection again")

list_colours = ["red", "blue", "green", "yellow", "magenta", "orange", "cyan"]
choices = []
for number in ["first", "second", "third", "fourth"]:
    choice, list_colours = selection(number, list_colours, choices)
    choices.append(choice)

print ("Choices made list =", choices)
woooee 814 Nearly a Posting Maven

In Tkinter is would just be
top.title("New Title")

Or use a Label and Entry box if you have several entries and want a separate title/label for each one.

Ah, you are using input, i.e. the console

x= input("blah blah blah")

then you would just print a line to get something more than "blah blah blah" to print

print("Python Input")
x= input("blah blah blah")
woooee 814 Nearly a Posting Maven

A more compact version of the snow program. I'm not obsessive really.

# drawing canvas/window with title and size
win = GraphWin("Snowman",400,500)

parts_is_parts = []
fill="white"
ctr = 0
for x, y, z in ((200, 115, 45), (200, 210, 65), (200, 345, 85), (180, 100, 3.5),
                (220, 100, 3.5), (170, 125, 3.5), (185, 132, 3.5), (200, 135, 3.5),
                (215, 132, 3.5), (230, 125, 3.5), (200, 175, 3.5), (200, 205, 3.5),
                (200, 235, 3.5)):
    cir = Circle(Point(x, y), z)
    cir.setFill(fill)
    cir.setOutline("black")
    cir.draw(win)
    parts_is_parts.append(cir)

    if 2 == ctr:
        fill="black"
    ctr += 1

hat = Rectangle(Point(290,150),Point(200,160))
hat.setFill("black")
hat.move(-43,-86)
hat.draw(win)
parts_is_parts.append(hat)
tophat = Rectangle(Point(30,30),Point(70,70))
tophat.setFill("black")
tophat.move(150,-7)
tophat.draw(win)
parts_is_parts.append(tophat)

nose = Polygon(Point(180,90),Point(130,100),Point(180,100))
nose.setFill("orange")
nose.move(20,18)
nose.draw(win)
parts_is_parts.append(nose)

incr = -40
for x, y in ((142, 185), (336, 145)):
    arm = Line(Point(x, y),Point(x-75, y+incr))
    arm.setFill("brown")
    arm.setWidth(3)
    arm.draw(win)
    parts_is_parts.append(arm)
    incr *= -1

snow = Circle(Point(100,100), 2)
snow.setFill("white")
snow.setOutline("blue")
snow.draw(win)
for x, y in ((-70, 150), (-60, 20), (-40, -70), (-40, 250), (-15, 50), (25, 100), 
             (50, -70), (150, 50), (190, -50), (200, 100), (200, 200), (230, -5), 
             (250, 150), (275, 30)):
    snow2 = snow.clone()
    snow2.move(x, y)
    snow2.draw(win)

for i in range(6):
    p = win.getMouse()
    c = parts_is_parts[0].getCenter()
    dx = p.getX() - c.getX()
    dy = p.getY() - c.getY()
    for part in parts_is_parts:
        part.move(dx,dy)

win.getMouse()
win.close()
woooee 814 Nearly a Posting Maven

See the definition for append mode = "a" Click Here which explains why checking is not necessary.

woooee 814 Nearly a Posting Maven

def replaceVariablesWithCsvData(self, headerRow, row, lines): # lines as list of strings

This function does not create a list. It creates one long string. For more precise help come up with a simple example and some test data so we can see what happens compared to what should happen.

woooee 814 Nearly a Posting Maven

This doesn't have anything to do with Python. See if the task manager gives a create time or does something simple, like number the processes sequentially so you can tell which is which. Perhaps someone else will know something more about Visual Basic and the Task Manager.

woooee 814 Nearly a Posting Maven

You should first test the calc_average function.
print calc_average(75, 75, 75, 60, 90)
Also you might want to convert to a float which depends on the version of Python you are using.

woooee 814 Nearly a Posting Maven

The epoch is OS dependent and has nothing to do with Python. Since we don't know what OS you are using the question can not be answered except to say print gmtime(0) and see what it tells you. 28800 seconds is something like 8 hours so it may be the difference between Greenwich time and local time.

woooee 814 Nearly a Posting Maven

And you first want to check that the index is in the dictionary to avoid an error message.

dictionary={a:1, b:2, c:3 ...etc}
lookup=[a, a, b, c, c ... etc]
results = [dictionary[key] for key in lookup if key in dictionary]
woooee 814 Nearly a Posting Maven

This statement is part of your problem

        self.master.bind('<Configure>', self.resize)

Also, you misspelled "tag". Other than that, moving the circle works fine for me. Since you always print the text in the same place and test the same coordinates, you will always get the same results. You have to keep track of the center of the circle and see if the mouse click location is within the radius, i.e use a right triangle to get the distance from the mouse click to the center and test for less than the radius.

I would make moveCircle less redundant with the following code. Finally, I would suggest that you select different names for the tags as "circle" and "text" can be confusing since Tkinter already uses those names.

    def moveCircle(self, event):
        """move circle up, down, left or right when user clicks an arrow key"""
        x=0
        y=0
        if event.keysym == "Up":
            y = -5
        elif event.keysym == "Down":
            y = 5
        elif event.keysym == "Left":
            x = -5
        else:
            x = 5

        self.canvas.move("circle", x, y)
        self.canvas.move("text", x, y)
        self.canvas.update()
woooee 814 Nearly a Posting Maven

Please read the sticky threads
Homework Help

If you have no idea then there is not much that can be done with this problem. I would suggest that you start with something easier where you do have some idea of what to do.

woooee 814 Nearly a Posting Maven

Start by printing x, y, and z. And print the return. These are always good places to start.

def calcdist(data):
    for p in data:
        x = p[:1]
        y = p[:2]
        z = p[:3]
        print "x, y, and z =", x, y, z

    for i in range(len(data)):
      dist = sqrt((x[i]-x[i+1])^2 + (y[i]-y[i+1])^2 +(z[i]-z[i+1]^2))
      print "returning", dist, "for", x, y, z
      return dist 

Finally, take a look here http://www.greenteapress.com/thinkpython/html/thinkpython007.html#@default466 for squares and square roots. Hint: the square code is incorrect.

woooee 814 Nearly a Posting Maven

What that post means is, you execute the return from rollin (which is 'None') because of the parens. It should be
rolldice = Tkinter.Button(row2, command=rollin, text = "Roll")
See Click Here for info on bindings and callbacks.

Also, you do not include the parens when you call dx.roll within rollin() so it does nothing. Finally, I like to use Tkinter variables because the widget is updated when the variables change. Otherwise you may have to call update_idletasks().

import random
import Tkinter

win = Tkinter.Tk()
win.title("Die Roller")
class die():
    import Tkinter
    def __init__(self,ivalue,parent):
        win.geometry("75x50+10+10")
        self.label_var = Tkinter.IntVar()
        self.label_var.set(ivalue)
        self.display = Tkinter.Label(parent,relief='ridge', borderwidth=2, 
                       textvariable=self.label_var)
        self.display.pack(side='left')

    def roll(self):
        value = random.randint(1,6)
        self.label_var.set(value)
        print "label_var =", value

def rollin():
    d1.roll()
    d2.roll()
    d3.roll()


row1 = Tkinter.Frame(win)
row2 = Tkinter.Frame(win)
d1 = die(1,row1)
d2 = die(1,row1)
d3 = die(1,row1)
##d1.display.pack(side="left")
##d2.display.pack(side="left")
##d3.display.pack(side="left")
row1.pack()
rolldice = Tkinter.Button(row2, command=rollin, text = "Roll")
rolldice.pack()
row2.pack()
win.mainloop()
woooee 814 Nearly a Posting Maven

It is very easy. Just lay it out in a list and print the list. A simplified example.

to_draw = [[" ", "O"],
           [" ", "|"],
           ["\\", " ", "/"],
           [" ", "|"],
           [" ", "|"],
           ["/", " ", "\\"]]

for each_list in to_draw:
    print "".join(each_list)
woooee 814 Nearly a Posting Maven

Use "SELECT" and "WHERE" to only return record(s) that match from the SQLite database See "Named Placeholders"

woooee 814 Nearly a Posting Maven

A rather long, but funny transcript where a "hacker/cracker" tries to crack someone else's computer. The catch is that the inept cracker is told that the IP address of the other computer is 127.0.0.1 [http://www.frihost.com/forums/vt-51466.html]

"This is a transcript of the worlds dummest hacker on an IRC channel. The comments are not mine, they belong to the original poster of the dialogue. I had to share this with you.....

Quote:
* bitchchecker (~java@euirc-a97f9137.dip.t-dialin.net) Quit (Ping timeout#)
* bitchchecker (~java@euirc-61a2169c.dip.t-dialin.net) has joined #stopHipHop
<bitchchecker> why do you kick me
<bitchchecker> can't you discus normally
<bitchchecker> answer!
<Elch> we didn't kick you
<Elch> you had a ping timeout: * bitchchecker (~java@euirc-a97f9137.dip.t-dialin.net) Quit (Ping timeout#)
<bitchchecker> what ping man
<bitchchecker> the timing of my pc is right
<bitchchecker> i even have dst
<bitchchecker> you banned me
<bitchchecker> amit it you son of a bitch
<HopperHunter|afk> LOL
<HopperHunter|afk> shit you're stupid, DST^^
<bitchchecker> shut your mouth WE HAVE DST!
<bitchchecker> for two weaks already
<bitchchecker> when you start your pc there is a message from windows that DST is applied.
<Elch> You're a real computer expert
<bitchchecker> shut up i hack you
<Elch> ok, i'm quiet, hope you don't show us how good a hacker you are ^^
<bitchchecker> tell me your network number man then you're dead
<Elch> Eh, it's 129.0.0.1
<Elch> or maybe 127.0.0.1
<Elch> yes …

happygeek commented: love it :) +0
nitin1 commented: ;) nice one +0
mike_2000_17 commented: this is hilarious! +0
woooee 814 Nearly a Posting Maven

FWIW, you can also use divmod instead of two statements (divide and mod), but I doubt that this code would be accepted from a beginning student, and only prints the plural form of the words.

x = input('Enter the before-tax price (in cents): ')
y = input('Enter your painment (in cents): ')
z = y - int(1.05 * x)
print 'Your change is: ', z
for divisor, lit in [(100, "Dollars"), (25, "Quarters"),
                      (10, "Dimes"), (5, "Nickels"), (1, "Pennies")]:
    whole, z = divmod(z, divisor)
    print "%9s = %d" % (lit, whole)

hotblink (Christopher Dela Paz) you should give at least an attempt to code this yourself. Most of us frown on doing homework for you.

+1

woooee 814 Nearly a Posting Maven

"I get a Type Error" tells nothing about the why. You must post the entire error message, which shows the offending line and the place in the line where the error occurs. If you use the exact same code to create all boxes using a loop or calling the same function (we don't know), then it is not related to ComboBox creation. Wx has been around for years so I seriously doubt that it has anything to do with Wx code that creates the ComboBoxes, but is instead related to the data, all other things being equal. Once again, print the result of the select statement, and/or use a different set of data to test with which should produce the error at a different place or not at all if your program uses the same code to create all boxes.

Gribouillis commented: well said +13
woooee 814 Nearly a Posting Maven

You should also get errors for

n = raw.input("Terms? ")

and for

b = m * m + m
first_term = ( ( n * n + n ) / 2 ) - 1

and the same as the above comment

if m != 0:   

will always be true the way the program is coded (hint: raw_input returns a string)

Start with one of the tutorials It is well worth the time spent. BTW, indentation errors that aren't obvious may be the mixing of tabs and spaces when indenting, and tabs can be given different values depending on the settings in your window manager. The "rule" is to only use spaces.

woooee 814 Nearly a Posting Maven

You have two instances of Tk running which is never a good idea. Use a Toplevel instead. The following is a very simple example. But it will not solve the problems. The problem is that you have somewhere around 100+ lines of code that have not been tested so you have not idea where the problem(s) are. Test each function individually before coding the next function.

class ChoiceTest():
    def __init__(self):
        self.root=tk.Tk()
        self.root.geometry("+5+5")
        tk.Label(self.root, text="\n Main Window \n").grid()
        tk.Button(self.root, text="Exit", command=self.root.quit).grid(row=1, column=0)
        self.choice_box("List")
        self.root.mainloop()

    def choice_box(self, choice):
        if choice == "List":
            self.win2 = tk.Toplevel(self.root)
            self.win2.title("List")
            self.win2.geometry("+100+100")
            self.list_text = tk.Label(self.win2, 
                       text="Please enter number\nof values to be used:")
            self.list_text.grid(row=0, column=0, sticky="nsew", 
                                 padx=1, pady=1)
            self.value = tk.StringVar()
            self.list_values = tk.Entry(self.win2, 
                        textvariable=self.value, justify="center")
            self.list_values.grid(row=1, column=0, sticky="nsew", padx=1, pady=1)
            tk.Button(self.win2, text="Continue", 
                      command=self.get_value).grid(row=2, column=0)

    def get_value(self):
        print self.value.get()
        self.win2.destroy()

CT=ChoiceTest()
TrustyTony commented: solid to the point advice +12
woooee 814 Nearly a Posting Maven

When happy hour is a nap

woooee 814 Nearly a Posting Maven

You also have to convert from strings in the file, to integers. A read and convert example

test_data="""1 4 5 3
 1 0 2 4 18
 5 2 0 0 9"""
#
##f = open(inputfile, "r")
f = test_data.split("\n")
#
output_list = []
for rec in f:
    numbers_as_strings = rec.split()
    print numbers_as_strings     ## while testing
    inner_list = []
    for num in numbers_as_strings:
        inner_list.append(int(num))
    output_list.append(inner_list)
#
print "\noutput_list =", output_list
woooee 814 Nearly a Posting Maven

You have to append a newline, "\n"

    for record in ['<table border="1" cellpadding="15" cellspacing="5" width="100%">',
                   '<tr>',
                   '<th colspan="2">Vysvedcenie</th>',
                   '</tr>',
                   '<tr>',
                   '<td width="50%">Meno, Priezvisko:</td>\<td>Skolsky rok:</td>',
                   '</tr>']
        ## number of lines truncated above           
        vytvor.write("%s\n" % (record))
vlady commented: it's nice solution! +2
woooee 814 Nearly a Posting Maven

I want to either figure out how to open the individual python files when I click on a button

That is too much code to go through, but you would include the "open the file" code in the call back function.

try:
    import Tkinter as tk     ## Python 2.x
except ImportError:
    import tkinter as tk     ## Python 3.x
#
def open_file():
    fp = open("./test_file", "r")
    for rec in fp:
        print rec
    fp.close()
#
## create a test file to open
fp = open("./test_file", "w")
fp.write("This is a test file\n")
fp.write("Second line")
fp.close()
#
root = tk.Tk()
tk.Button(root, text="Open a File", command=open_file).grid()
root.mainloop()