woooee 814 Nearly a Posting Maven

The objective is to list the occurrences of vowels in a given word, such that for (word = yellow) and index spits out (e = 1, o = 1)

This (e = 1, o = 1) is not the position/occurrences so I am assuming you want to count the number of times each vowel occurs.

if letters in vowels:
            if letters not in count:
                count[letters]=0     ## add to dictionary, initialize counter to zero

            count[letters] += 1  ## add one to a counter
woooee 814 Nearly a Posting Maven

You would send the values to a function and return the amounts.

def payment(principle, monthly_interest_rate, amount_paid):
    """ assumes a payment is made every month so there are no penalties 
    """
    if principle > 0:     ## loan is not paid off
        interest_due = monthly_interest_rate * principle
        if amount_paid < interest_due:
            print "Payment does not cover interest so nothing done"
        else:
            to_principle = amount_paid - interest_due
            if principle-to_principle > 0:
                principle -= to_principle
                print "You paid %9.2f in interest and %9.2f reduced the principle to %9.2f" % \
                      (interest_due, to_principle, principle)
            else:    # more paid than is owed
                print "You paid off the principle of %9.2f and are being returned %9.2f" % \
                      (principle, to_principle-principle)
    else:
        print "Your loan is paid off.  Congratulations"
    return principle

principle = 100000
interest_rate = 0.06/12
for amount in [1000.11, 100, 10000, 500, 100000]:
    principle=payment(principle, interest_rate, amount)

You can also use one function for all input

def get_input(lit, low, high):
    while 1:
        print "-"*50
        print "Enter a number between %9.2f and %9.2f" % (low, high)
        amount=raw_input(lit)
       
        ## catch anything entered that is not a number
        try:
            amt_float=float(amount)
            if low <= amt_float <= high:
                return amt_float
        except:
            print "Enter numbers only"

years=get_input("Enter payment term in years: ", 1, 30)
yearly_interest=get_input("Enter annual interest rate as %: ", 1, 10)
principle=get_input("Enter principal amount in $: ", 1000, 500000)
anniversary=get_input("Enter the anniversary payment percentage:", 0, 10)

Copied with [code] [/code] tags attached (and do you get extra credit for lots of empty lines).

# This program calculates a …
woooee 814 Nearly a Posting Maven

It is probably the blackslash which has a unique meaning in programming. Python uses a forward slash and converts depending on the OS. You can insert quotes just like any other string.

quote='"'
#  changed to a forward slash
soxxy = '%stools/sox.exe%s "%s.wav" "%ssox.wav" compand 0.3,1 6:-60,-50,-30 -14 -90 0.2 
 gain -n -1' % (quote, quote, name, name)
# etc.
print soxxy

# or use join
name = "xyz"
start_list=['"tools/sox.exe"',
           '"%s.wav"' % (name),
           '"%ssox.wav"' % (name),
           'compand 0.3,1 6:-60,-50,-30 -14 -90 0.2  gain -n -1']

print " ".join(start_list)
woooee 814 Nearly a Posting Maven

I would guess the problem to be the columnspan or sticky parameters. You can try different combinations of those, but also might want to post to a Tkinter forum like Manning's as many of us use the Pmw extension which has scrollbars built in.

woooee 814 Nearly a Posting Maven

This should work (note the single quote at the beginning and end-Python uses both/either) but print "soxxy" to be sure.
soxxy = '"tools\sox.exe" "%s.wav" "%ssox.wav" compand 0.3,1 6:-60,-50,-30 -14 -90 0.2
gain -n -1' % (name, name)

woooee 814 Nearly a Posting Maven

Lists are the easiest and quickest way to work with data IMHO. You can then join the elements into one string http://www.diveintopython.net/native_data_types/joining_lists.html.

a = "01101000011001010111100100000000000000000000"


b = "011000100111100101100101"

combined_list=[]
combined_list.append(b)
combined_list.append(a[len(b):])  ## slice off length of "b"
print "".join(combined_list)

## result
01100010011110010110010100000000000000000000
woooee 814 Nearly a Posting Maven

Another way is to use a third class as a wrapper. The buttons in the following code print the contents of the variable from the other class. Also, it is never a good idea to create two or more instances of a GUI at the same time. It can cause confusion with the interaction from the display manager. Use one of instance of wx and separate frames.

import wx

class Test1():
    def __init__(self, parent, id, title):
        self.ident="Test1 Ident"
        self.frame=wx.Frame(None, id, title, size=(170, 100))
        self.frame.SetPosition((10, 10))

    def exit_button(self, T2):
        panel = wx.Panel(self.frame, -1)
        exit = wx.Button(panel, -1, 'Exit 1'+T2.ident, (10, 10))

        exit.Bind(wx.EVT_BUTTON,  self.exit_this, id=exit.GetId())
        self.frame.Show(True)

    def exit_this(self, event):
        self.frame.Close()

class Test2():
    def __init__(self, parent, id, title, wrap):
        self.ident="Test2"
        self.frame=wx.Frame(None, id, title, size=(170, 100))
        self.frame.SetPosition((10, 150))

        panel = wx.Panel(self.frame, -1)
        exit = wx.Button(panel, -1, 'Exit Two-->'+wrap.T1.ident, (10, 10))
        exit.Bind(wx.EVT_BUTTON,  self.exit_this, id=exit.GetId())

        self.frame.Show(True)

    def exit_this(self, event):
        self.frame.Close()

class Wrapper():
    def __init__(self):
        app = wx.App()
        self.T1=Test1(None, -1, '')
        self.T2=Test2(None, -1, '', self)
        self.T1.exit_button(self.T2)
        app.MainLoop()

W = Wrapper()
woooee 814 Nearly a Posting Maven

You would use a while() loop or function for this, Search the web for either as there are many examples of password entry. Some pseudo-code

def get_pw():
    while 1:
        pw=raw_input()
        if pw is correct:
            return
woooee 814 Nearly a Posting Maven

Since the only difference is the image on the button, you would reset the image for each button in "gumb" to "karirano".

woooee 814 Nearly a Posting Maven

You would have to store all of the initial values and change the values back when the button in pressed. Or, generally you use a class to run a Tkinter application so you can destroy the class instance and create it again. Some example code would help us help you as we don't know what "everything" in "put everything as it was in moment I started program" means.

woooee 814 Nearly a Posting Maven

You have an infinite loop because all of the returns call main() again. BTW main is a bad name for a function because it is not descriptive. Some instructors use it in their beginning courses so as to not confuse the students with functions that have different names. In your case main() serves no purpose as you can just run the code without it. If you know lists, you can reduce a lot of the redundant code using a list.

def inches(start):
    convert_to = [["feet", 0], ["miles", 0], ["millimeters",0],
                  ["centimeters", 0], ["meters", 0], ["kilometers", 0]]
    for item in convert_to:
        print item[0]
    end = raw_input("Convert to? ")
    value = input("Value? ")
    convert_to[0][1] = value / 12.0      ## feet
    convert_to[1][1] = value / 63360.0   ## miles
    convert_to[2][1] = value * 25.4      ## etc
    convert_to[3][1] = value * 2.54
    convert_to[4][1] = value * 0.0254
    convert_to[5][1] = value * .0000254
    for item in convert_to:
        if end == item[0]:
            print "%s to %s, %7.2f = %7.2f" % (start, end, value, item[1])
start = raw_input ("Convert from? ")
inches(start)

Finally, the usual strategy is to convert everything to a common base and then convert from that common base to the desired unit, so there is one function that converts everything to inches or millimeters and passes that value to the conversion function, which reduces code in the remaining functions as they only have one unit to convert.

woooee 814 Nearly a Posting Maven

"Chinese authorities are investigating eggs which bounce after being boiled and may make men sterile...the eggs' hardness could be a natural occurrence, caused by hens consuming large amounts of food enriched with a compound called gossypol, which binds to protein in egg yolks...While gossypol normally exists in the residue of cotton seeds [and is] added to chicken feed as an extra protein source, large doses of the compound will suppress sperm activity as gossypol has been tested to be used in male contraceptive pills,"

woooee 814 Nearly a Posting Maven

You have to have access to the button object and set enabled to False. I don't know of anyone here who uses PythonCard so we can't help much.

woooee 814 Nearly a Posting Maven

Generally you use GetLabel() or event.GetEventObject().GetLabel(). Search on those for some examples.

woooee 814 Nearly a Posting Maven

You have not declared Button1 in the code you posted so there is nothing to disable. But generally it is

b.config(state=DISABLED)

where "b" is the button's ID as returned by Tkinter. Also, you import Tkinter in two different ways (pick one only)

import Tkinter
from Tkinter import *

Do not mix wxPython and Tkinter

import Tkinter
import wx

"os.path" is available once you import os

import os
import os.path

And you only have to import subprocess once.

import subprocess
import subprocess as sp
from subprocess import Popen

One of Grayson's examples (click "He's dead" to disable)

from Tkinter import *

def disable_button():
    b1.config(state=DISABLED)

root = Tk()
root.title('Buttons')
Label(root, text="You shot him!").pack(pady=10)
b1=Button(root, text="He's dead!", command=disable_button)
b1.pack(side=LEFT)
Button(root, text="He's completely dead!", command=root.quit).pack(side=RIGHT)
root.mainloop()
woooee 814 Nearly a Posting Maven

You can condense all of the print statements if you want.

print """Welcome to The Great Text Adventure!
One day you wake up, in a room, locked in by yourself.

Could there be a key?
In the room you see."""

You can also use a list to eliminate redundant code.

## the same for keylocation, unlockeddoor, etc.
    choice_list = ["North and found a bridge over a canyon.",
                   "South and found a bridge over a river.",
                   "East and found a tunnel through a mountain.",
                   "West and found a tunnel through a mountain."]
    incorrect_list=["North and found a canyon. You had to turn around.",
                    "South and found a river. You had to turn around.",
                    "East and found a mountain. You had to turn around.",
                    "West and found a river. You had to turn around."]

    if 0 <= choice <= 3:
        print "You walked 2 miles",
        if choice == correctdirection:
            print choice_list[choice]
            loop3 = 0
        else:
            print incorrect_list[choice]
        print ""
woooee 814 Nearly a Posting Maven

The palindrome function only compares the first and last numbers. You have to compare all of them. To reverse an integer without converting to a string you divide by ten.

def palindrome(num_in):
    reversed_num = 0
    whole = num_in
    while whole > 0:
        whole, remain = divmod(whole, 10)
        reversed_num = reversed_num*10 + remain

    print reversed_num,
    if reversed_num == num_in:
        print "is palindrome"
    else:
        print "NOT a palindrome"

palindrome(12345)
palindrome(12321)
woooee 814 Nearly a Posting Maven

Everything should go under the if statement (indents count in Python), or copy the file you want to process to a list and process the list.

def treeDir (arg, dirpath, basenames):
    workspace = dirpath
    roads_list = []
    for f in basenames:
        if f.startswith('roads.'):
            fullf = os.path.join(dirpath,f)
            function_to_process_this_file(fullf)

            ##
            ## or
            roads_list.append(fullf)

    ## all files are processed
    for fname in roads_list:
        function_to_process_this_file(fname)
woooee 814 Nearly a Posting Maven

As Tony stated, you can iterate over a file

#f = open('lorumipsum.txt');

# simulate the file 
f=["Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\n",
 "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit\n",
 "esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit\n",
 "anim id est\n",
 "laborum\n"]

for rec in f:
    print rec[::-1]  ## using slicing to reverse 

# but you can also do it with a loop
for rec in f:
    reversed_list = []
    for ctr in range(len(rec)-1, -1, -1):  ## go from last letter to the first
        ## string concatenation is slow and expensive
        ## append to a list and join()
        reversed_list.append(rec[ctr])
    print "".join(reversed_list)
woooee 814 Nearly a Posting Maven

In the OnPlus function, the program will sleep for 1*5000 seconds which is about 1 1/2 hours. In the OnMinus function also, you add/subtract one from value but it has no meaning i.e is not displayed. You should test each function individually as you create it, otherwise you will be stuck with a large block of code and no idea where the error is. Finally, please read the Python Style Guide concerning naming conventions. It makes code easier to read and understand.

woooee 814 Nearly a Posting Maven

SELECT * FROM PLAYERS WHERE NAME = ''pete' OR '1'='1''
with an error message

There is a syntax error here that has nothing to do with MySQL or injection. Your query breaks down into
''
pete
' OR '
1
'='
1
'
In the future please include the entire error message if you want some help.

woooee 814 Nearly a Posting Maven

You should start a new thread with one of the questions only, and the code that you have tried. For example, where is the data coming from in the first question? If from a file, then the file has to be read.

woooee 814 Nearly a Posting Maven

Quoted to show indentation. Use "count" instead.

S1="""AACAAGAAGAAAGCCCGCCCGGAAGCAGCTCAATCAGGAGGCTGGGCTGGAATGACAGCG
CAGCGGGGCCTGAAACTATTTATATCCCAAAGCTCCTCTCAGATAAACACAAATGACTGC
GTTCTGCCTGCACTCGGGCTATTGCGAGGACAGAGAGCTGGTGCTCCATTGGCGTGAAGT
CTCCAGGGCCAGAAGGGGCCTTTGTCGCTTCCTCACAAGGCACAAGTTCCCCTTCTGCTT
CCCCGAGAAAGGTTTGGTAGGGGTGGTGGTTTAGTGCCTATAGAACAAGGCATTTCGCTT
CCTAGACGGTGAAATGAAAGGGAAAAAAAGGACACCTAATCTCCTACAAATGGTCTTTAG
TAAAGGAACCGTGTCTAAGCGCTAAGAACTGCGCAAAGTATAAATTATCAGCCGGAACGA
GCAAACAGACGGAGTTTTAAAAGATAAATACGCATTTTTTTCCGCCGTAGCTCCCAGGCC
AGCATTCCTGTGGGAAGCAAGTGGAAACCCTATAGCGCTCTCGCAGTTAGGAAGGAGGGG
TGGGGCTGTCCCTGGATTTCTTCTCGGTCTCTGCAGAGACAATCCAGAGGGAGACAGTGG
ATTCACTGCCCCCAATGCTTCTAAAACGGGGAGACAAAACAAAAAAAAACAAACTTCGGG
TTACCATCGGGGAACAGGACCGACGCCCAGGGCCACCAGCCCAGATCAAACAGCCCGCGT
CTCGGCGCTGCGGCTCAGCCCGACACACTCCCGCGCAAGCGCAGCCGCCCCCCCGCCCCG
GGGGCCCGCTGACTACCCCACACAGCCTCCGCCGCGCCCTCGGCGGGCTCAGGTGGCTGC
GACGCGCTCCGGCCCAGGTGGCGGCCGGCCGCCCAGCCTCCCCGCCTGCTGGCGGGAGAA
ACCATCTCCTCTGGCGGGGGTAGGGGCGGAGCTGGCGTCCGCCCACACCGGAAGAGGAAG
TCTAAGCGCCGGAAGTGGTGGGCATTCTGGGTAACGAGCTATTTACTTCCTGCGGGTGCA
CAGGCTGTGGTCGTCTATCTCCCTGTTGTTC"""

for lit in ["GAAT", "CAA"]:
    print lit, S1.count(lit)

I have text file as follows seq.txt

>S1
AACAAGAAGAAAGCCCGCCCGGAAGCAGCTCAATCAGGAGGCTGGGCTGGAATGACAGCG
CAGCGGGGCCTGAAACTATTTATATCCCAAAGCTCCTCTCAGATAAACACAAATGACTGC
GTTCTGCCTGCACTCGGGCTATTGCGAGGACAGAGAGCTGGTGCTCCATTGGCGTGAAGT
CTCCAGGGCCAGAAGGGGCCTTTGTCGCTTCCTCACAAGGCACAAGTTCCCCTTCTGCTT
CCCCGAGAAAGGTTTGGTAGGGGTGGTGGTTTAGTGCCTATAGAACAAGGCATTTCGCTT
CCTAGACGGTGAAATGAAAGGGAAAAAAAGGACACCTAATCTCCTACAAATGGTCTTTAG
TAAAGGAACCGTGTCTAAGCGCTAAGAACTGCGCAAAGTATAAATTATCAGCCGGAACGA
GCAAACAGACGGAGTTTTAAAAGATAAATACGCATTTTTTTCCGCCGTAGCTCCCAGGCC
AGCATTCCTGTGGGAAGCAAGTGGAAACCCTATAGCGCTCTCGCAGTTAGGAAGGAGGGG
TGGGGCTGTCCCTGGATTTCTTCTCGGTCTCTGCAGAGACAATCCAGAGGGAGACAGTGG
ATTCACTGCCCCCAATGCTTCTAAAACGGGGAGACAAAACAAAAAAAAACAAACTTCGGG
TTACCATCGGGGAACAGGACCGACGCCCAGGGCCACCAGCCCAGATCAAACAGCCCGCGT
CTCGGCGCTGCGGCTCAGCCCGACACACTCCCGCGCAAGCGCAGCCGCCCCCCCGCCCCG
GGGGCCCGCTGACTACCCCACACAGCCTCCGCCGCGCCCTCGGCGGGCTCAGGTGGCTGC
GACGCGCTCCGGCCCAGGTGGCGGCCGGCCGCCCAGCCTCCCCGCCTGCTGGCGGGAGAA
ACCATCTCCTCTGGCGGGGGTAGGGGCGGAGCTGGCGTCCGCCCACACCGGAAGAGGAAG
TCTAAGCGCCGGAAGTGGTGGGCATTCTGGGTAACGAGCTATTTACTTCCTGCGGGTGCA
CAGGCTGTGGTCGTCTATCTCCCTGTTGTTC

>S2
ACACGCATTCACTAAACATATTTACTATGTGCCAGGCACTGTTCTCAGTGCTGGGGATAT
AGCAGTGAAGAAACAGAAACCCTTGCACTCACTGAGCTCATATCTTAGGGTGAGAAACAG
TTATTAAGCAAGATCAGGATGGAAAACAGATGGTACGGTAGTGTGAAATGCTAAAGAGAA
AAATAACTACGGAAAAGGGATAGGAAGTGTGTGTATCGCAGTTGACTTATTTGTTCGCGT
TGTTTACCTGCGTTCTGTCTGCATCTCCCACTAAACTGTAAGCTCTACATCTCCCATCTG
TCTTATTTACCAATGCCAACCGGGGCTCAGCGCAGCGCCTGACACACAGCAGGCAGCTGA
CAGACAGGTGTTGAGCAAGGAGCAAAGGCGCATCTTCATTGCTCTGTCCTTGCTTCTAGG
AGGCGAATTGGGAAATCCAGAGGGAAAGGAAAAGCGAGGAAAGTGGCTCGCTTTTGGCGC
TGGGGAAGAGGTGTACAGTGAGCAGTCACGCTCAGAGCTGGCTTGGGGGACACTCTCACG
CTCAGGAGAGGGACAGAGCGACAGAGGCGCTCGCAGCAGCGCGCTGTACAGGTGCAACAG
CTTAGGCATTTCTATCCCTATTTTTACAGCGAGGGACACTGGGCCTCAGAAAGGGAAGTG
CCTTCCCAAGCTCCAACTGCTCATAAGCAGTCAACCTTGTCTAAGTCCAGGTCTGAAGTC
CTGGAGCGATTCTCCACCCACCACGACCACTCACCTACTCGCCTGCGCTTCACCTCACGT
GAGGATTTTCCAGGTTCCTCCCAGTCTCTGGGTAGGCGGGGAGCGCTTAGCAGGTATCAC
CTATAAGAAAATGAGAATGGGTTGGGGGCCGGTGCAAGACAAGAATATCCTGACTGTGAT
TGGTTGAATTGGCTGCCATTCCCAAAACGAGCTTTGGCGCCCGGTCTCATTCGTTCCCAG
CAGGCCCTGCGCGCGGCAACATGGCGGGGTCCAGGTGGAGGTCTTGAGGCTATCAGATCG
GTATGGCATTGGCGTCCGGGCCCGCAAGGCG

.
.
.
.
I have to count patterns in these sequences to achieve python script
But it is giving the wrong result. The script is reading line by line.

S1 : 0
S1 : 0
S1 : 0
S1 : 0
S2 : 0
S2 : 1
S2 : 0
S2 : 1
But I want output as follows:

S1 : 0
S2 : 2
Can anybody help?

import re

infile = open("seq.txt", 'r')

out = open("pat.txt", 'w')

pattern = re.compile("GAAAT", flags=re.IGNORECASE)


for line in infile:
   line = line.strip("\n")
   if line.startswith('>'):
      name = line
   else:
      s = re.findall(pattern,line)

      print '%s:%s' %(name,s)
      out.write('%s:\t%s\n' %(name,len(s)))
woooee 814 Nearly a Posting Maven
woooee 814 Nearly a Posting Maven

Come up with a test suite, with known numbers and known results to test with. Also, you don't know if multiplication or division is done first so this line
a= (sum1 / r*1.0)
can lead to unexpected results. And I think that multiplication and division would evaluate left to right, so division would be done first=division result is an integer*1.0. Print the result to see for yourself. Instead, convert the numerator or denominator to a float as you do later in the code, or convert "r*1.0" on a separate line or add parens.

Don't use the same name as in can confuse the compiler in some situations.

def SD():
    .....
    SD = (float(L)/r)**0.5
vegaseat commented: good point +15
woooee 814 Nearly a Posting Maven

Generally you set it to the length of the first record that is not blank/empty.

woooee 814 Nearly a Posting Maven

It would be an else statement after the blankline code

if line.startswith('\n'):
        blankline = blankline + 1 
    else:
        if len(line.strip()) < shortest:
            shortest = len(line.strip())

# or better yet
     line = line.strip()
     if len(line) == 0:
        blankline = blankline + 1 
    else:
        if len(line) < shortest:
            shortest = len(line)
# and 
        if len(line) > largelinelen:  ## same indent level
woooee 814 Nearly a Posting Maven

"Why is this taking so long" is a question that is too general for you to answer. So learn to use profiling. The first few sentences read
"The first step to speeding up your program is learning where the bottlenecks lie. It hardly makes sense to optimize code that is never executed or that already runs fast. I use two modules to help locate the hotspots in my code, profile and trace."

woooee 814 Nearly a Posting Maven

The error appears to be on the previous line. First, make sure that this is actually a Python3 package and not a Python2 package. There are many packages that have not been ported to Python3x.

woooee 814 Nearly a Posting Maven

Bet you didn't know the US has a Beard Team.

Burke Kenny, a 26-year-old Olympia, Wash., man took first place in the 2011 World Beard and Mustache Championships "full beard with styled mustache" category, officials say. Kenny began growing his winning beard and mustache combo when he was about 20 while attending Evergreen State College; his biggest facial hair influence is his father. Kenny is one of six Beard Team USA members to take home gold medals from this year's championship, four of whom are from Washington state.

woooee 814 Nearly a Posting Maven

Instead of the dictionary, which is fine, you can add 12 to the time if "PM" and less than 12. And another point that is picky for the example, but relevant in other things you might do, is to use endswith instead of in, to only catch AM of PM if they are at the end of the string.

t_lower = tstr.strip().lower()
	if t_lower.endswith("am"):
		return am[a[0]] + a[1][:2] + 'hr'
	elif t_lower.endswith("pm"):
		return pm[a[0]] + a[1][:2] + 'hr'
        else:
            return "ERROR in " + tstr
woooee 814 Nearly a Posting Maven

You use "replace" so it replaces all text that is equal (duplicates), when you should slice off the word.

def split_word(word, numOfChar):
	r = []
#	h = len(word)/numOfChar     ## not used
	while True:
		if len(word) == 0:
			return r
		else:
			r.append(word[0:numOfChar])
			word = word[numOfChar:]         ## changed
	return r

print split_word("Asentencewithduplicateduplicatewords", 5)
woooee 814 Nearly a Posting Maven

Sets are the way to go

# assumes each square is numbered 1 thorugh 9, not 0 through 8
##             rows, columns, & diagonals
winner_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9], \
               [1, 4, 7], [2, 5, 8], [3, 6, 9], \
               [1, 5, 9], [3, 5, 7]]

""" use something like
for winner in winner_list:
    if set(winner).issubset(player_set):

so
tictactoe([('X', ' ', 'O'), 
           (' ', 'O', 'O'), 
           ('X', 'X', 'X') ])
becomes [1, 7, 8, 9] for X
and [3, 5, 6] for O

A tie = all squares filled and no winner
""" 
X=[1, 7, 8, 9]
for winner in winner_list:
    if set(winner).issubset(set(X)):
        print "Is a winner", winner
woooee 814 Nearly a Posting Maven

Some suggestions; use a for() loop to pick a random number on each pass, and another list/tuple for the values corresponding to the random number. Also, it is personal preference, but you can use a function to get the input and only return when the input is recognized. A subset of the code you posted:

import random

def Reels():

    # [0]Winning Value, [1]Fruit, [2]Fruit, [3]Fruit
    Ret_Val = [0," "," "," "]

    values = ( (1, "Banana"), (5, "Orange"), (20, "Cherry") )

    # Spin those reels !
    for ctr in range(1, 4):  ## corresponds to element number in Ret_Val
        Reel_Spin = random.randrange(0,3,1)  ## element number in values
        this_wheel = values[Reel_Spin]
        Ret_Val[0] += this_wheel[0]
        Ret_Val[ctr] = this_wheel[1]

    return Ret_Val

def user_input(Jack_Pot, Player_Money):
    """ User input
        Return True and the bet amount, or False and zero to exit
    """
    while 1:
        print("\n Place Your Bet ! \n Jackpot $%-9.2f" % (Jack_Pot))
        print(" Money = $%-9.2f " % (Player_Money))
        print(" Q = quit ")
        Bet_Line = input(" ")

        if Bet_Line in ["q", "Q"]:
            return False, 0

        try:
            Bet = int(Bet_Line)
            return True, Bet
        except:
            print("Error: '" + Bet_Line + "' is not a number !")


Jack_Pot=2000
Player_Money=100

bet_placed, Bet = user_input(Jack_Pot, Player_Money)
while bet_placed:
    # Not enough money
    if Bet >= Player_Money:
        print("Sorry, you only have $%-d \n" % (Player_Money))
    else:
        print Reels()

    bet_placed, Bet = user_input(Jack_Pot, Player_Money)  ## get next bet
woooee 814 Nearly a Posting Maven

Put the code under the try or in a function and call the function under the try

def read_file(infile):
    tex1 = infile.readline()
    outfile = open ('Book11.txt', "w")
    while tex1:
        rfields = tex1.split()

    # do something


    print >> outfile, 'something'


    outfile.close()
    infile.close()

try:
    infile = open ('Book1.txt', "r")
    read_file(infile)
    
except IOError:
    print "input file %s is missing" %'Book1.txt'
except:
    print "Some other error"
woooee 814 Nearly a Posting Maven

Tic-Tac-Toe or Hangman are more common starting points. Then perhaps poker or blackjack.

woooee 814 Nearly a Posting Maven

Use a list http://www.greenteapress.com/thinkpython/html/book011.html

input_list = []
while True:
	ID = input('> ')
	if ID == 'exit':     ## "is" is different from equal
		break
	else:
		input_list.append(ID)

print input_list

or a dictionary http://www.greenteapress.com/thinkpython/html/book012.html

number = 1     ## integers remove leading zeros automatically
input_dict = {}
while True:
	key = 'A%03d' % (number)
        number += 1
	ID = input('> ')
	if ID == 'exit':
		break
        ## technically, else is not required as break will exit the while loop
	else:
		input_dict[key] = ID

print "-"*70
print input_dict

print "-"*70
for key in input_dict:
    print key, "----->", input_dict[key]
woooee 814 Nearly a Posting Maven

The question itself is not clear

from start to the end number (inclusive)

but the results do not include the end number

range(1, 11, 2) will return a list of numbers [1,3,5,7,9]

.

woooee 814 Nearly a Posting Maven

First, these while() loops and/or "break" are not necessary

if command == "look up":
        print "You look up to the ceiling but nothing of any use is up there."
#        break
    elif command == "look down":
#        while 1:
            print "You look down you are sat on a bed."
#            break

Your code would then loop but would never exit, so you should add an exit option and a break.

while 1:
    command = raw_input("What do you do?: ")
    if command == "look up":
        print "You look up to the ceiling but nothing of any use is up there."
#        break
 
    elif command == "look down":
#        while 1:
            print "You look down you are sat on a bed."
#            break

    elif command == "exit":
        break     ## exits the while loop

print "Bye, Bye"

To get some movement you would use a common function which you would pass a direction to, and possibly distance, and the function would move the player in that direction.

while 1:
    command = raw_input("What do you do?: ")
    if command == "look up":
        print "You look up to the ceiling but nothing of any use is up there."
#        break
 
    elif command == "look down":
#        while 1:
            print "You look down you are sat on a bed."
#            break
    elif command == "move right":
       distance = raw_input("How far do you want to move? ")
       move(player, int(distance), "right")
    elif command == "exit":
        break     ## exits the while loop
woooee 814 Nearly a Posting Maven

See the grid manager here or here.

woooee 814 Nearly a Posting Maven

You should probably ask this question on the Daniweb MS Windows forum that corresponds to your version as this is an "install software on Windows" question and not a Python question.

woooee 814 Nearly a Posting Maven

I would suggest that you start with a tutorial on passing and returning parameters in functions like this one, and also read up on changing variables, see "Arithmetic Operators" here, as this question is covered in every tutorial and too simple to be asking someone else about. Your code, modified so it runs

def grid(c, z):  #Z is the X coord, C is the Y coord
    print ("Which way would you like to move? X, -X, Y, or -Y?")
    a = raw_input()
    if a == "X":
        z += 1
    elif a == "-X":
        z -= 1
    elif a == "Y":
        c += 1
    elif a == "-Y":
        c -= 1

    return c, z

c = 2
z = 3
print(c, z)
for ctr in range(3):
    c, z = grid(c, z)
    print(c, z)
woooee 814 Nearly a Posting Maven

NoneType means that delitem deletes in place so
list.__delitem__(index)
works for your code, and
list = list.__delitem__(index)
binds "list" to the return value=None. Also, choose a name other than "list" as that is already used by Python to convert to a list.

woooee 814 Nearly a Posting Maven

since 1 is less than two

Then it is not one. Add a print statement to show what is being compared.

def Fitness(a,b,c):
	      f = [a,b,c]
              print "comparing", f[0:2], "against 2, 3, and 4"
	      if f[0:2] >= 4 and sum(f) >= 13:
		      print 'Gold'
	      elif f[0:2] >= 3 and sum(f) >= 10:
		      print 'Silver'
	      elif f[0:2] >= 2 and sum(f) >= 7:
		      print 'Pass'
	      else:
		      print 'Fail'

Also, store the sum in a field instead of calculating it several times, and min will give you the smallest number in the list.

def Fitness(a,b,c):
    f = [a,b,c]
    total = sum(f)
    smallest = min(f)
    if smallest >= 4 and total >= 13:
        print 'Gold'
    ## etc.
woooee 814 Nearly a Posting Maven

Indents are incorrect

ag_fname = wx.FileDialog(self, defaultFile="", style=wx.OPEN)
        if ag_fname.ShowModal() == wx.ID_OK:
            gif = ag_fname.GetPath()
 
            gif1 = wx.animate.GIFAnimationCtrl(panel, id, gif, pos=(75,10),
                                            size=(200,200))
            gif1.Play()
        else:
            print "Could not find the file"
woooee 814 Nearly a Posting Maven

the gif-frame stops but the tiny Tk-win wont stop

The stop button is only bound to the wxpython widgets. You would have to have a separate stop button in Tkinter, or as stated above, the usual process is to code everything using the same tool kit.

woooee 814 Nearly a Posting Maven

pow is a function in the "math" program

import math
print r"pow(2,3) returns 2^3-->", math.pow(2,3)
woooee 814 Nearly a Posting Maven

A simple example:

def print_grid(a_grid):
    print "The Grid"
    for row in a_grid:
        print " |".join(row)
        print "--+--+--"
    print " X axis"
    print "\n"

y = int(raw_input("How tall do you want the grid to be?" "(type a to exit) "))
x = int(raw_input("How long do you want the grid to be? "))
a_grid = []
for a_row in range(x):
    row = [str(a_row+col) for col in range(y)] # fill with anything unique for testing
    a_grid.append(row)
print a_grid         ## just the container
print_grid(a_grid)

## change a cell
a_grid[1][2] = "Xx"     ## assumes this grid is at least 2X3
print_grid(a_grid)
woooee 814 Nearly a Posting Maven

but I have no idea how I would label it

The labels would be outside of "grid" if you want to use it in a game, and so change the contents. They would be incorporated in a print_grid() function as the only time you require labels is when the grid is printed.. It is possible, but places unnecessary complexity to include the labels or any formatting characters in the container as you would no longer have a simple row and column assignment, but would have to adjust for the labels.

woooee 814 Nearly a Posting Maven
for number in range(a,b,c):

This prints a number starting with "a", ending at "b", and the step/increment is "c". What happens if b<a?

if len(x)== 2:
            a=x[0]
            b=x[1]+c         ## <----- "c" does not exist at this point
            c=1

Also you can just use

else:                   
        x_str_array = x_str.split(',') # splits the string where a comma pops up
        a=int(x_str_array[0])    ## length !=0 so this will be used in all cases
        if len(x_str_array)==3:
            b=int(x_str_array[1])
            c=int(x_str_array[2])
        ## etc.