woooee 814 Nearly a Posting Maven

This appears to work for the given test data.

test_data = open("./tmp/GL581_54270_28321_28325.dat", "rb").read()
all_groups = test_data.split("BASELINE")
print len(all_groups)

fp_out = open("./tmp/test_output", "wb")
for group in all_groups[1:]:     ## removes empty, first split occurance
    sep = group.partition("\n")
    fp_out.write("BASELINE %s\n" % (sep[0]))
    for x in range(12):
        sep = sep[2].partition("\n")
        fp_out.write("%s\n" % (sep[0]))
        fp_out.write("-" * 50)
        fp_out.write("\n")
    fp_out.write(sep[2])
    fp_out.write("\n")
    fp_out.write("*"*50)
    fp_out.write("\n\n")
fp_out.close()
woooee 814 Nearly a Posting Maven

The middle rectangle, be it red or white is centered, so if you have a 200x200 canvas, the middle would be 100. You can then move left or right, calculating the end position of the first red square for the rows with 4 red squares; end position=middle - (1.5 white + 1 red). The other row is obviously rectangles of the same size.

woooee 814 Nearly a Posting Maven

Tab is not necessary. Try this code, which will accept anything, letters, numbers, equal signs, etc.

ltr_str = raw_input("Enter 10 letters ")
while len(ltr_str) != 10:
    ltr_str = raw_input("Enter 10 letters and 10 letters only ")
printed = 0
for ltr in ltr_str:     ## access each individually
    print ltr,
    printed += 1
    if printed > 2:
        print
        printed = 0
print

If you want to enter words, separate with a comma and then split() the input on the comma. Commas are the most commonly used delimiter.

words_str = "dog, fog, log, bog, gog, hog, jog, nog, rog, tog" # from input
words_list = words_str.split(",")
printed = 0
for word in words_list:
    print word.strip(),
    printed += 1
    if printed > 2:
        print
        printed = 0
print

Another problem is after i found a word on the grid.. lets say i searched for the word
"hi" - it is found in the grid at [2][1] and thats what i want to print... but when i try to print it it prints this way: [ 2 ][ 1 ]

No way to tell without code.

woooee 814 Nearly a Posting Maven

i made a start but i cant make it work with the colour nor adding size dimensions.

That is a little vague. Post one function with a description of what you want it to do. Also in getWidth() and getHeight() it will error out in Python 2.X if a non-digit is entered (what version of Python are you using?). You should catch errors or use raw_input and test the string using isdigit() before converting to an int. And both of these functions, getWidth and getHeight, are the same except for the literal printed. You can use one function and pass "width" or "height" to it. Finally, note the difference in the variable names here

def drawPatchOne(win, Colours, y):
        #patch1.setFill(colour)
woooee 814 Nearly a Posting Maven

You don't need recursion for this. Are you sure you are not supposed to sort in reverse order, i.e. maximum value is first. You can think of recursion as a while loop, with a function calling itself instead of looping.

woooee 814 Nearly a Posting Maven

It appears the the backslash is being escaped by Python. Try repr(the_string) as output and see if it helps.

woooee 814 Nearly a Posting Maven

Using x,y coordinates confuses things IMHO. You can just number each square and enter one number for that square. This also simplifies keeping track of moves as you can use a single list with one element for each square on the board.

woooee 814 Nearly a Posting Maven

I don't have a lot of time, but here is a simple example to start you, using Tkinter. The other GUI toolkits, WxPython and QT, would be similar.

from Tkinter import *

root = Tk()
root.title('Rectangle Test')
canvas = Canvas(root, width =300, height=300)

## top_left_x, top_left_y, bottom_right_x, bottom_right_y
points_list = [0, 0, 25, 25]
color = "red"

for row in range(3):
    for col in range(3):
        rectang = canvas.create_rectangle(points_list[0], points_list[1], \
                              points_list[2], points_list[3], fill=color)
        ## increase along the x axis
        for point in [0, 2]:
            points_list[point] += 50

    ## move down one row
    if row%2:      ## row is an odd number
        points_list = [ 0, points_list[1]+25, 25, points_list[3]+25]
    else:          ## row is an even number
        points_list = [25, points_list[1]+25, 50, points_list[3]+25]

canvas.pack()
root.mainloop()
woooee 814 Nearly a Posting Maven

You search a dictionary in this way, and note that names would be case sensitive:

def search(dict1):
    name2=raw_input("Enter the name whose number is to be found: ")
    if name2 in dict1:
        print name2, dict1[name]
woooee 814 Nearly a Posting Maven

Draw it out first, then program each part individually and then put them together. To get you started, here is part of the right-most picture. Continue with a separate function to draw the other half (columns side), and then look at a way to combine them. It you can not combine them, then so be it. The old saying is, first you make it work, then you make it fast, then you make it pretty.

from graphics import *

def draw_patch(win, colour, side_length):
    ## 5 red rectangles and 5 white rectangles = skip this much
    ## to go from one red row to the next, i.e. skip one red+white combo
    width = side_length / 5
    for row in range(5):
        ## divide row by 2 because skip one row = red + white 
        ## divide width by 4 because it prints only 1/2 of the square (left
        ##     or right half), and 1/2 of red+white block

        ## left side
        draw_rows(width*row/2, win, colour, side_length, width/4)
        ## right side
        draw_rows(side_length-width*row/2, win, colour, side_length, width/4*-1)
     
def draw_rows(offset, win, colour, side_length, width):
    bl = Point(offset, offset)                   ## bottom left
    tr = Point(offset+width, side_length-offset) ## top right
    rectangle = Rectangle(bl, tr)
    rectangle.setFill(colour)
    rectangle.draw(win)

win = GraphWin("Patch", 200, 200)
draw_patch(win, 'red', 200)
 
raw_input("Press Enter")
woooee 814 Nearly a Posting Maven

There is an example in the turtle graphics demo of the Python docs that come with Python.

woooee 814 Nearly a Posting Maven

You don't have any button or other widget variable "Quit". You possibly want to store the memory address for the buttons in a list and then use button_list[3].clicked() as it is the last/fourth button created. Using the local symbol table is somewhat obfuscated code IMHO.

woooee 814 Nearly a Posting Maven

You can do that in two ways, the second way is usually preferred because everything is contained in the class:

import random

class Kortlek():
    def __init__(self,colors=["blue   ", "yellow ", "red    "], \
                 forms=["triangel", "circle  ", "square  "], \
                 numbers=[1, 2, 3], grades=[1, 2, 3]):
        self.cardList = []
        self.playerCardList = []
        self.lista3 = []

        ## add something to lista3
        for x in range(5):
            self.lista3.append(random.randint(1, 10))

    def print_list(self):
        print self.lista3

KC = Kortlek()
print KC.lista3
print
KC.print_list()
woooee 814 Nearly a Posting Maven

Please don't post 54 lines of untested crap here and ask up to clean up your mess. Test each function individually. For example: What happens when you enter 2 students here:

def getNumber(number):
 
    number = input('Enter a number between 2 and 30: ')
    while number <=2 or number >=30:
        print'You must enter a number between 2 and 30'
        number = input('Enter a number between 2 and 30:')
 
    return number

What does this function return if I have already defined 5 students and enter "20" 5 times. It should return 20X5=100. I do not see why you want to return "number" as well.

#this function will get the total scores
def getScores(totalScores, number):
    for counter in range(0, number):
        score = input('Enter their score: ')
    while score<=10 or score>=100:
        print'You must enter a number between 0 and 100'
        score = input('Enter a number between 0 and 100:')
 
 
        totalScores = totalScores + score
        return totalScores, number 
#
# To test this you would call it and print the results
print getScores(0, 5)

Also to clean it up a bit, you do not have to pass averageScores to this function because it is calculated and returned by the function.

#this function will calculate the average
def getAverage(totalScores, averageScores, number):
    averageScores = totalScores / number
    return averageScores

Please test the code first so you don't waste our time or you will find that no one wants to answer your question.

woooee 814 Nearly a Posting Maven

You also should test for length before you draw cards:

def cards(self):
    if len(self.cardList) > 5):
        for a in random.sample(self.cardList, 6):
woooee 814 Nearly a Posting Maven

Hey, I've got an array full of random numbers

It depends on how many levels are in the array. Generally, you would flatten the array into a single level list, and operate on that. If you want to keep the original structure, then you have to test for the type. If it is an integer you can modify if. If it is a list, then you have to traverse the inner list. Recursion would probably be the best choice for doing that.

woooee 814 Nearly a Posting Maven

If you are using Python3.X, then input will return a string which is always greater than 100, print type(score) to see which class it belongs to.

woooee 814 Nearly a Posting Maven

The advantages of Multiprocessing are:
it does not use a GIL and
it can use multiple cores if you are on a multi-core machine.
This means that it is usually faster, but it ultimately comes down to what you understand and can use.

woooee 814 Nearly a Posting Maven

It appears the the zero is being read as minutes and the one as the hour. I doubt any of the cron programmers allowed for someone entering "01" instead of just "1".

woooee 814 Nearly a Posting Maven

Post a link to a sample file that we can use for testing when/if you want to take this tread any further.

woooee 814 Nearly a Posting Maven

Start by using a turtle triangle for the tree, add a small rectangle for the tree stump, and then modify the triangle to look more tree like.

woooee 814 Nearly a Posting Maven

Generally you begin with the input

The user will enter a molecule with each atom individually (CO2 would be entered as): C O O...The user should continue to be asked for more molecules until they enter a blank line.

Next would be the dictionary you spoke of, sign-->mass, and looking up each atom so as to add the mass to a total.

woooee 814 Nearly a Posting Maven

Note also that you start with zero, not one, and your zero replaces 21, and your 21 replaces 16. One problem is that you generate 26 numbers, zero through 25, with only 25 spaces to hold them. I have no other advice because "And here is what the square is supposed to print" yields this solution:
print "11 18 25 2 9"
etc. as there is nothing else that can be deduced from the question.

woooee 814 Nearly a Posting Maven

Since the text in the example posted appears to end with a newline, you should be able to test a reasonable length of characters, I'm using 30, for the newline and if not found, or 13 text records were found, you have the start of the binary data. An example of how you could do that follows. Another way is to test for "BASELINE" and group the data from the start of "BASELINE" to the next occurrence. You could then start at the end position of each group and slice 262144 bytes. The following appears easier to understand to me but it is personal choice. For more specific info you should include a link to part of an actual file with a 5-10 of these record groups.

file_read = """BASELINE NUM: 258\n
MJD: 54270\n
SECONDS: 28321\n
CONFIG INDEX: 0\n
SOURCE INDEX: 2\n
FREQ INDEX: 0\n
POLARISATION PAIR: RR\n
PULSAR BIN: 0\n
FLAGGED: 0\n
WEIGHTS WRITTEN: 0\n
U (METRES): -18954.5\n
V (METRES): 99486.5\n
W (METRES): 54117.25\n
<F1><AA><E8><U+0084>^]^NDeR.<U+0085><B2><D4>B<D8>m<8B><C1><B3><91><E2>A<AA>f)
<C1>A<91>Ad<DD> <C1>^L^^%AESC<91><U+037F>c<9E> A^F<BE>0]<8D>@H<F8>^M<C0>m<D8>]@@3<F7>^W@<FF>^Z<96>><B6><B0><E9>@g<AA><CE>?dl<86>?^\<ED><FE><BD><BF><82><88>@<E8>"""

def find_newline(test_this):
    print "test_this =", test_this
    for ctr, ch in enumerate(test_this):
        ## this should work but you may have to use "if ord(ch) == 10"
        if ch == "\n":
            return ctr
    return -1

position = 0
new_position = 0
text_list = []
while new_position > -1:
    new_position = find_newline(file_read[position:position+30])
    print position, new_position
    if new_position > -1:
        text_list.append(file_read[position:position+new_position])  ## removes "\n"
        ## change the following +2 to +1 because "\n" is 2 bytes in the example
        ## but is a decimal …
woooee 814 Nearly a Posting Maven

Hundreds of records is not much in today's world so you can read each file into a dictionary and go from there. A simple example to associate the two files because I am too tired to do more today. You can omit some of the unnecessary records from the dictionary or use as is and filter before writing to the third file.

## simulate 2 files read into lists using readlines()
file_1 = ['SU' ,
'PD-98059 PD-98059 Tanimoto from SU = 0.129213',
'BML-265 BML-265 Tanimoto from SU = 0.163743',
'BML-257 BML-257 Tanimoto from SU = 0.156627',
'SU 4312 SU 4312 Tanimoto from SU = 1',
'AG-370 AG-370 Tanimoto from SU = 0.264286',
'AG-490 AG-490 Tanimoto from SU = 0.347826',
'PD-98060 PD-98059 Tanimoto from SU = 0.129213',
'BML-265 BML-265 Tanimoto from SU = 0.163743',
'BML-257 BML-257 Tanimoto from SU = 0.156627',
'SU 4312 SU 4312 Tanimoto from SU = 1',
'AG-370 AG-370 Tanimoto from SU = 0.264286',
'AG-490 AG-490 Tanimoto from SU = 0.347826',
'PD-98061 PD-98060 Tanimoto from SU = 0.129213',
'BML-265 BML-265 Tanimoto from SU = 0.163743',
'BML-257 BML-257 Tanimoto from SU = 0.156627',
'SU 4312 SU 4312 Tanimoto from SU = 1',
'AG-370 AG-370 Tanimoto from SU = 0.264286',
'AG-490 AG-490 Tanimoto from SU = 0.347826']


file_2 = ['GF',
'PD-98059 PD-98059 Tanimoto from GF = 0.118483',
'BML-265 BML-265 Tanimoto from GF = 0.164179',
'BML-257 BML-257 Tanimoto from GF = 0.213904',
'SU 4312 SU 4312 Tanimoto from GF = 0.436364',
'AG-370 AG-370 Tanimoto from GF = 0.284848',
'AG-490 AG-490 …
woooee 814 Nearly a Posting Maven

It depends somewhat on what widget you want to set, but generally you can use configure. This is something I have lying around from somewhere and added a configure to change the background and foreground of the button when the top button is pressed. Another example is here. You also want to become familiar with the class structure as it is much easier to pass variables around when coding a GUI. The example at the link posted shows how to use a class for this.

from Tkinter import *

def callback1() :
    print "Callback #1"
    option1.configure(bg = 'white', fg='green')

def callback2() :
    print "Callback #2"

def callback3() :
    print "Callback #3"

##===============================================================
top = Tk()

##---  always place in upper left corner ( +10+10 )
##     size = 200x200 = minimum size so it's big enough to be seen
top.geometry("150x150+10+10" )

label1 = Label( top, text = "Test Menu" )
label1.pack()

label2 = Label( top, text = "" )          ## blank line = spacer
label2.pack()

option1 = Button(top, text='Option 1',
       command=callback1, bg='blue', fg='white' )
option1.pack(fill=X, expand=1)

option2 = Button(top, text='Option 2',
       command=callback2, bg='green', fg='white' )
option2.pack(fill=X, expand=1)

option3 = Button(top, text='Option 3 - No Exit',
       command=callback3, bg='black', fg='white' )
option3.pack(fill=X, expand=1)

exit=  Button(top, text='EXIT',
       command=top.quit, bg='red', fg='white' )
exit.pack(fill=X, expand=1)

top.mainloop()
woooee 814 Nearly a Posting Maven

I'm sure I could but I'm not the one who's taking the class.

vegaseat commented: right on +13
woooee 814 Nearly a Posting Maven

Adding a print statement should help. If you want to store more than one value, a list is usually the container of choice.

def gp(a1,r,n):
    ## can also be done with list comprehension
    print [ a1 * (r ** x) for x in range(n)]

    while n > 0:
        n = n - 1   ## if 'n' was 1 it is now zero
        an = a1 * (r ** n)
        print n, "returning", an
        return an
woooee 814 Nearly a Posting Maven

You would have to test for "(" and then traverse (or split) to the ")". The letters in between would be divided by 1000.

woooee 814 Nearly a Posting Maven

I'm not sure what you are asking, but see if this helps:

## last line under main()
    print "points for one", point_one.x, point_one.y
    print "points for two", point_two.x, point_two.y
#
# and add this additional function to Triangle and call it
    def print_points(self):
        print self.A.x, self.A.y
        print self.B.x, self.B.y
        print self.C.x, self.C.y 
## also under main()
    triangle_one.print_points()

A big part of the problem is lazy naming. How in the hell can you tell what "self.A.x" contains?

woooee 814 Nearly a Posting Maven

It looks like you have 13 lines of normal text, by which I mean that you could open it normally and read the first 13 lines normally, and count the bytes to skip. Then close the file, open as binary and skip the number of bytes that contained text, but it is not easy to tell from the example.

woooee 814 Nearly a Posting Maven

Works fine for me. Note that you only have to pass minutes allowed and minutes used to the function.

def calc_total(minutesAllowed, minutesUsed):
 
    extra = 0
 
    if minutesUsed <= minutesAllowed:
        totalDue =74.99
        minutesOver = 0
        print "You were not over your minutes for the month."        
    else:
        minutesOver = minutesUsed - minutesAllowed
        extra = minutesOver * .20
        totalDue = 74.99 + extra
        print "You were over your minutes by ",minutesOver
 
    return totalDue, minutesOver

print calc_total(100, 90)
print calc_total(100, 110)
"""
You were not over your minutes for the month.
(74.99, 0)

You were over your minutes by  10
(76.99, 10)
"""

And what do you think does/does not happen here

print minutesAllowed, minutesOver, minutesUsed, totalDue
        calcTotal(minutesAllowed, minutesOver, minutesUsed, totalDue)
        print minutesAllowed, minutesOver, minutesUsed, totalDue
woooee 814 Nearly a Posting Maven

This is my opinion of what you are asking, but a better example would help:

def add_a(list_in, list_a, s):
    for x in range(s):
        if len(list_in):
            list_in.append(list_a[0])
            del list_a[0]        
    return list_in, list_a

def add_b(list_in, list_b, n):
    for x in range(n):
        list_in.extend(list_b)    
    return list_in

a = 'a'
b = 'b'
list_a = [a, ] * 15
list_b = [b,]
s = 5
n = 2

next_list = []

## append first n=2
next_list = add_b(next_list, list_b, n)

while len(list_a):
    ## append "s" number of "a"
    next_list, list_a = add_a(next_list, list_a, s)

    ## append n*n list_b
    if len(list_a):
        for x in range(n):
            next_list = add_b(next_list, list_b, n)

## append last n=2
next_list = add_b(next_list, list_b, n)
print next_list
woooee 814 Nearly a Posting Maven

Python uses pointers, which means that D=C assigns the memory address of "C" to "D" so they both point to the same block of memory.

woooee 814 Nearly a Posting Maven

There are still 50 cent pieces but you don't see them much, so the first thing is to find out what coins are acceptable.

woooee 814 Nearly a Posting Maven

There have been several examples on Daniweb alone http://www.daniweb.com/forums/thread246963.html

woooee 814 Nearly a Posting Maven
# the last letter is b,d,g,l,m,n,p,r,s or t 
if word[wordlength] in ['b','d','g','l','m','n','p','r','s','t']:

    #and the second to last letter is not the same as the last letter.
    if word[wordlength] != word[wordlength-1]:
#
# or (same thing as nested if() statements)
if (word[wordlength] in ['b','d','g','l','m','n','p','r','s','t']) and \
   (word[wordlength] != word[wordlength-1]):
#
# also only the replace can be used here (but the whole idea is incorrect)
# because a new string is created, so replace can be one or many characters
    if word[wordlength]=="y":
        word=word.replace('y', 'ier') ## *****test this with the word yummy*****
#        word=word +'er'              ## slice off the last "y" instead and add "ier"
woooee 814 Nearly a Posting Maven

The Python program I need to write accepts the price of an item, the amount paid for it

Start by asking and receiving from the keyboard, the price and the amount paid. Yes, we can help you with code you've written, but won't do it for you.

woooee 814 Nearly a Posting Maven

"\n" is the newline character, so you are appending a newline every time you write "answer", so remove it there and add a statement to b.write "\n" every time a comma is found (and it is not apparent from the code posted how you test for a comma). Note that you can use either "readline()" or "for line in a:" but not both.

woooee 814 Nearly a Posting Maven

The short answer is to use withdraw or iconify but not all methods are available for all widgets. A simple example that creates a normal Tk window, and a second window with a canvas that is withdrawn when you click the "Continue" button, and is raised with the "deconify" button. This is a quickie and so is crude but illustrates this.

import Tkinter

class TestClass():

   def __init__(self):
      self.top = Tkinter.Tk()
      self.top.title("Test")
      self.top.geometry("200x150+500+5")

      frame_1 = Tkinter.Toplevel()
      frame_1.title("frame 1")

      but_1 = Tkinter.Button(self.top, text='deiconify',                        
              command=frame_1.deiconify)                                        
      but_1.pack(side="bottom", fill=Tkinter.X, expand=1) 

      but_2 = Tkinter.Button(self.top, text='Quit',
              command=self.top.quit, bg='blue', fg='yellow')
      but_2.pack(side="bottom", fill=Tkinter.X, expand=1)

      can_1 = Tkinter.Canvas(frame_1)
      can_1.pack()
      can_1.create_rectangle(50,50,100,100, outline='white', fill='black')

      cont = Tkinter.Button(frame_1, text='CONTINUE',
              command=frame_1.withdraw, bg='red', fg='white' )
      cont.pack(side="bottom", fill=Tkinter.X, expand=1)


      self.top.mainloop()
         
##====================================================================
if __name__ == '__main__':
   CT=TestClass()
woooee 814 Nearly a Posting Maven

If I can read the 166 lines of code correctly, what happens when "resting" == 1

info_dict["resting"] = info_dict["resting"] - 1
## it now equals zero, so the following would never execute
        def slime_move_ready():
            ## also add a print statement to see if this is executing
            print 'info_dict["resting"]', info_dict["resting"]
            if info_dict["resting"] > 0:
                health.after(100, slime_move)

Also, use a tuple or another dictionary to replace all of the if() statements.

if info_dict["slime_spot"] == 1:
                data = "east","east"
            if info_dict["slime_spot"] == 2:
                data = "west","south"
            if info_dict["slime_spot"] == 3:
                data = "east","south"
##   etc, etc.
##   becomes
info_tuple = ( ("", ""), ("east","east"), ("west","south"), ("east","south"))
info_dict = {"slime_spot":2 }    ## test it
num = info_dict["slime_spot"]
data = info_tuple[num]   ## or info_tuple[info_dict["slime_spot"]]
print data
woooee 814 Nearly a Posting Maven

I would keep everything between the first ">" and "<" but if all of the records are the same, you could also replace "<TimeStamp>" and "</TimeStamp>" with nothing. Either way will get you to be able to
print(datetime.datetime.fromtimestamp(int("1284101485")).strftime('%Y-%m-%d %H:%M:%S'))

woooee 814 Nearly a Posting Maven

For the unknowing, this is another example of the "never-ending-questions-with-little-or-no-code" method to get other people to write the code for them. The method is to keep asking questions until someone is worn down enough to write the code for them, while they sit on the veranda in the shade. Let this thread die as it should.

woooee 814 Nearly a Posting Maven

You would call it this way (an intro to classes):

##Test the Lexicon program
print'This is a test program for the Lexicon file'

# an instance of the class
lex_instance = Lexicon()
# the class instance now exists so we can call it's members
source = lex_instance.OpenFile('word')
woooee 814 Nearly a Posting Maven

Connect stderr to a pipe, and you also have to flush the pipes, see, "Doug Hellmann's Interacting with Another Command" which is what I think you want to do. Also take a look at pexpect which should suffice from what you have explained, and is simple to use.

woooee 814 Nearly a Posting Maven

faces=rect64(acb64583d1eb84cb),2623af3d8cb8e040;rect64(58bf441388df9592),d85d127e5c45cdc2

It appears that you could split on the comma and then on the semi-colon since you want the last string in the pair. Then flatten the resulting list. Otherwise, parse each line and look for a start and stop copying character (which may be easier to understand and is a skill that is necessary in a lot of real world applications).

woooee 814 Nearly a Posting Maven

[b,b,a,a,a,a,a,b,b,b,b,a,a,a,a,a,b,b,b,b,a,a,a,a,a,b,b]

You insert 2, then 4, then 4, then 2? Please correct this example or be more specific about what you want.

Instead of inserting, it is more efficient to create a new list since every item past the insertion point has to be moved for every insert. You can use 2 for() loops; the first would have an increment or step value of s. The second or inner loop would append n values of 'b'. The outer loop would then append s values of 'a' before looping again. If the length of the original list is not always divisible by s, then you would have to test for less than length before appending an 'a' This could probably be done with list comprehension, but many do not consider it a basic skill. Try out some double for() loop code for yourself and post back with questions on that code as it is physically impossible for the few of us who answer to provide code for everyone who asks.

woooee 814 Nearly a Posting Maven

launcher.get_config() // this should get me the IPs and their respective shares
trial.randomtask(2)

It gets the ip's and then destroys the dictionary because you don't store the return. You would then pass the returned dictionary, or an individual ip with shares, to the randomtask function.

woooee 814 Nearly a Posting Maven

In the future, you would probably receive more answers with a small block of code that illustrates what you want to do, rather than 135 lines of untested code.

val2 = raw_input("Vill du spela igen? Ja/Nej ")
 
        val2 = "Ja"
 
        while val2 != "Ja":

            if val2 =="Ja":

A simple selection example:

import random
import string
choose_from = list(string.lowercase)
for j in range(5):
    choices = random.sample(choose_from, 3)
    print choices, "-->", choose_from, "\n"
    choose_from = [x for x in choose_from if x not in choices]
woooee 814 Nearly a Posting Maven

Print what you have first because it doesn't look like it is doing what you would want if "number_list" is a string and has not been split into words.

def turn_words_into_numbers(number_list):
    output = 0
    current = 0
    for index in range(len(number_list)):
        current = eval(number_list[index])
        print index, number_list[index]

Some theory: it may work better to reverse the list of words first. That way, "two hundred" becomes "hundred", "two" and you can set a multiplier to 100 to multiply the next word by. I am also using tuples to store the numbers, but you can use a list of lists as well. This assumes that you are not familiar with dictionaries, which would be a better choice. A simple example (doesn't have teens or twenty, thirty, etc.):

start = "two hundred and three"
rev = start.split()
rev.reverse()
print rev

ones = ("zero", "one", "two", "three", "four")
multiplier = (("hundred", 100), ("thousand", 1000))
multiply_by = 1
total = 0
for num in rev:
    print num
    ##  search for next number in ones tuple
    if num in ones:
        idx = ones.index(num)
        total += idx * multiply_by  ## index is the same as the number
        multiply_by = 1
    else:
        for tup in multiplier:
            if tup[0] == num:
                multiply_by  = tup[1]
print total