woooee 814 Nearly a Posting Maven

The 2 lines gave it away. There should be some relation between them. I take it that you verified that the answer is indeed correct.

woooee 814 Nearly a Posting Maven

So this is a case of "two wrongs make you write"? Ba dum bum...

I will have to use that somewhere myself.

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

Possibly
I to L = 3 letters, L to P = 4 letters
5 to 9 = 4, 9 to 14 = 5
so
I 9 P 20 =6+14
5 L 14 U =P+5 letters

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

It gives me that error am I doing something wrong

We don't know what the error is so there is no way to answer other than to ask what happens if nothing is found in the data base. Try printing the look up before adding to the combobox.

woooee 814 Nearly a Posting Maven

To end the game if there is a tie, set the last "while True" to some varialble instead that goes to False when there are no more empty spaces, like

empty_space=True
while empty space:
    input = raw_input("Select a spot: ")
    input = int(input)
    ## rest of code

    empty_space=test_for_empty(board)

To get the computer to try to win requires that you have a list of moves to counter each move of the opponent. Mostly, it is block any compbination of 2 in a row, and don't let the opponent get a corner where they can line up 2 possible wins. You can also simplify the code with lists.

def checkAll(char):
    wins_list = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [1, 4, 7], [2, 5, 8],
                  [0, 4, 8], [2, 4, 6]]
    for each_list in wins_list:
        if check_line(ch, win_list[0], win_list[1], win_list[2]):
            return True

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

And similarly for printing the winner, both print the same thing except for "X" or "O" so send the x/o to a function that will print the winner so there is one block of code instead of two.

woooee 814 Nearly a Posting Maven

Your list contains "option 1", etc, not "1".

options = [
'option 1',
'option 2',
'option 3'
]

while True:
    playerOpt = int(input('input '))
    list_test = "option %d" % (playerOpt)
    if list_test in options:
        break  ## exit while()
    print("\n Not a valid entry\n")
woooee 814 Nearly a Posting Maven

Just to see what it would take, modifying Ene's code to draw a right angle triangle of unknown dimensions is just a little more tedious

import turtle as tu
import random

tu.title('draw a right angle triangle')
# set at 50% of original size
tu.setup(width=0.5, height=0.5)

tu.up()
tu.goto(60, 100)
tu.down()

# optional pen color
tu.color('red')

hypotenuse=random.randint(100, 200)
base=random.randint(10, 99)
side = (hypotenuse**2 - base**2)**0.5
## round up the "old" way
side += 0.5
side = int(side)

for distance in (base, side):
    tu.forward(distance)
    tu.right(90)

## since we are using whole numbers, the sides will not be exact,
## so go to the starting point
tu.goto(60, 100)

# keep showing until window corner x is clicked
tu.done()
woooee 814 Nearly a Posting Maven

the checking starts with 0 (list indeces start with 0)

Lists don't have indexes, lists use offsets. So "some_list[5]" means offset 5 from the beginning, or skip over the first 5 elements=beginning of the sixth. It comes from the beginning days of computers when programmers had to do everything for themselves. If a list contained fixed length elements and you wanted to start reading from the beginning of the sixth element, you would move the memory or file pointer ahead 5*length-of-element. For example, if the list contained 2 byte integers you would skip over the first 10 bytes and read the next 2. If you want the first element, you would skip 0 bytes, etc. Today, Python takes care of this for you.

woooee 814 Nearly a Posting Maven

There are many examples on the web so no reason to duplicate answers here. Start with this link:
http://www.daniweb.com/software-development/python/code/216557/turtle-graphics-python

woooee 814 Nearly a Posting Maven

But this doesn't do exactly what I want... anyone help?

How are we supposed to know what this means?

In general, you want to compare words to words. Your code will also find sub-words, ie. "the" is in "then" and "and" is in "random", so use == instead for word to word, or better yet create a dictionary of words pointing to their ranking and look up each word in the dictionary.

Edit: duplicate of this post http://python-forum.org/pythonforum/viewtopic.php?f=18&t=36620

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

It depends on what is in "letters". If your OS is set to ASCII then the latin1 characters will not be found.

woooee 814 Nearly a Posting Maven

From NYTimes.com

Bradley Birkenfeld, a former banker at UBS, recently completed a 2.5-year prison sentence for conspiring with a wealthy California developer to evade United States income taxes.

But Mr. Birkenfeld, 47, has a lot to show for his time and effort: The Internal Revenue Service acknowledged Tuesday that information he provided was so helpful he would receive a $104 million whistle-blower award for revealing the secrets of the Swiss banking system.

Divulging the schemes that UBS used to encourage American citizens to dodge their taxes, Mr. Birkenfeld led to an investigation that has greatly diminished Switzerland’s status as a secret haven for American tax cheats and allowed the United States Treasury to recover billions in unpaid taxes.

In addition to the $780 million that the Swiss bank paid in 2008 to avoid criminal prosecution, the bank turned over account information regarding 4,700 American clients.

The unprecedented disclosure of Swiss banking information — which caused a fierce political debate in Switzerland before ultimately winning approval from the country’s parliament — set off such a panic among wealthy Americans that more than 14,000 of them joined a tax amnesty program. I.R.S. officials say the amnesty has helped them recover more than $5 billion in unpaid taxes.

woooee 814 Nearly a Posting Maven

There is no guarantee that "entry" is in the dictionary. You should do something like

_boolean_states = {'1': True, 'yes': True, 'true': True,
               '0': False, 'no': False, 'false': False}    

entry=entry.lower()
for field in expected_fields:
    if field == bool and entry in _boolean_states:
        entry=_boolean_states[entry]
woooee 814 Nearly a Posting Maven

I can't seem to find a solution for writing the data into a .csv format where all keys and values are separated by a delimiter, e.g. 11,2.5,2.7,32.6 ? Perhaps it would be a better idea to write it out into a formatted .txt file instead?

Using a txt file and writing to it so it is a csv file would be a good solution here

f3 = open('file3.csv', "w") 
...

x, y, z = f1_dict_data[key] 
if key in f2_dict_data:
    x, y, z = f2_dict_data[key] 
f3.write("%s, %s, %s, %s\n" % (key, x, y, z))

I will to sort the data produced in file 3 by the "Node" in ascending order, I have tried ways of doing so without any success.?

First, "Node" appears to be an integer so you have to convert to an integer before using it as the key for the dictionary, otherwise it sorts and compares as a string and will give different results. Then sort the keys and access the dictionary in sorted order, this assumes that you do not know if the original files are in order or not.

for node1, x1, y1, z1 in f1:
    f1_dict_data[int(node1)] = x1,y1,z1

f1_keys = f1_dict_data.keys()
f1_keys.sort()
for key in f1_keys:
    x, y, z = f1_dict_data[key] 
    if key in f2_dict_data:
        x, y, z = f2_dict_data[key] 
    f3.write("%d,%s,%s,%s\n" % (key, x, y, z))
woooee 814 Nearly a Posting Maven

researchers reported Sept. 5 in the journal PLoS ONE that black mustard gives off a specific scent when large cabbage white butterflies (Pieris brassicae), as they are called, lay eggs on it. This odor both repels other pregnant butterflies from laying more eggs on the plant and attracts two species of parasitic wasps, Trichogramma brassicae and Cotesia glomerata. The wasps swoop in and attack the butterfly eggs and the caterpillars that have hatched from them, the researchers said. This defense mechanism prevents a colony of caterpillars from feasting on its leaves. (In return, the wasps parasitize, or live off, these eggs.)

woooee 814 Nearly a Posting Maven

You would use len()

print sline[5], type(sline[5]), bool(len(sline[5]))

or eval(), although eval will do anything, so if someone puts "rm *" in the file that is being read, eval will delete the files.

for lit in ["False", "True"]:
    x = eval(lit)
    print x, type(x)
woooee 814 Nearly a Posting Maven

Note that the list you posted is not a list of tuples. You can use the older method to do this, although it is slower.

def return_lower(x, y):
    return cmp(x[0][1:], y[0][1:])

test_list=[('a070918_215953.SFTC', '1369.000'), ('a070917_220602.SFTC', '1369.000'),
 ('a070915_221210.SFTC', '1369.000'), ('r080323_044006.SFTC', '1369.000')]

print sorted(test_list, cmp=return_lower)
woooee 814 Nearly a Posting Maven

Simple debugging will point out the error. Try running the code with these additional print statements.

def occurrence(e, input_list):
    for item in input_list:
        print "checking" item, e  ## test for checking every item
        s = 0
        if item == e:
            print "     found, s =", s  ## this will clarify the problem
            s += 1
    return s
woooee 814 Nearly a Posting Maven

I ran into some trouble today while trying to launch idle from it
from tkinter import *

For starters, you should not run apps that use Tkinter from Idle since Idle is written in Tkinter. The results are unpredictable, so try again without using Idle and post back if there are still errors.

woooee 814 Nearly a Posting Maven

Use os.path.isdir() and os.path.islink() to identify which is which and then compare. As far as splitting goes, I would use something along these lines

import os
test_path="C:/Pyth/Shortcuts/1000.lnk"
first, second = os.path.split(test_path)
print first, second
print second.split(".")
woooee 814 Nearly a Posting Maven

You would bind <Button-3> to the item Click Here. For whitespace, you would have to test event.x and event.y to see if you are over white space or not. This uses a left click to determine the location (event.x, event.y) to draw the snowman, but the principle is the same. For anything more detailed, you will have to post your code. Anyone who has been in any forum for even a short time knows that guessing what the OP is trying to do is a complete waste of time.

from Tkinter import *

class Snowman:
    def __init__(self, root):
        self.cv = Canvas( root, width=300, height=300 )
        self.cv.create_text( 150, 20, text="Left-Click anywhere", \
                             font="Arial" )
        self.draw_snowman(150, 150)

        self.cv.bind( "<Button-1>", self.change_coord )
        self.cv.pack()

    def change_coord(self, event):
        self.cv.delete( self.head, self.body, self.arm1, self.arm2 )
        self.draw_snowman(event.x, event.y)

    def draw_snowman(self, x, y):
        self.head = self.cv.create_oval( x-10, y-10, x+10, y+10, fill="white" )
        self.body = self.cv.create_oval( x-15, y+10, x+15, y+40, fill="white" )
        self.arm1 = self.cv.create_oval( x-20, y+15, x-10, y+30, fill="white" )
        self.arm2 = self.cv.create_oval( x+20, y+15, x+10, y+30, fill="white" )

top = Tk()
Snowman(top)
mainloop()
woooee 814 Nearly a Posting Maven

Test for length after you strip the line, and note that "new" is already used by Python.

for line in keep:
    if len(line.strip()):
        new_fp.write(line)
woooee 814 Nearly a Posting Maven

Generally you pass the value to the function as you want the code "encapslated", i.e. the class does everything.

class Foot:
    def __init__(self,mov,posx,posy,targx,targy):
        # self.mov is soldier's movement speed, currently not implemented
        self.mov = mov
        # self.x and self.y are soldier's position
        self.x = posx
        self.y = posy
        # self.targx and self.targy are soldier's x and y target destinations
        self.targx = targx
        self.targy = targy

    def advancex(self, targx):
        # advancex(self) adjusts soldier's x position to match the target x position 
        if self.x > targx:
            self.x = self.x - 1
        elif self.x < targx:
            self.x = self.x + 1

        """ the rest does nothing
        else:
            self.x = self.x
        return self.x
        """

sold1 = Foot(0, 4, 6, 0, 1)
sold1.advancex(1)
print "x is now", sold1.x
sold1.advancex(-2)
print "x is now", sold1.x

You can change the variables outside of the class, but that is not the preferred way.

class Foot:
    def __init__(self,mov,posx,posy,targx,targy):
        # self.mov is soldier's movement speed, currently not implemented
        self.mov = mov
        # self.x and self.y are soldier's position
        self.x = posx
        self.y = posy
        # self.targx and self.targy are soldier's x and y target destinations
        self.targx = targx
        self.targy = targy

    def advancex(self):
        # advancex(self) adjusts soldier's x position to match the target x position 
        if self.x > self.targx:
            self.x = self.x - 1
        elif self.x < self.targx:
            self.x = self.x + 1

sold1 = Foot(0, 4, 6, 0, 1)
sold1.targx = 1
sold1.advancex()
print "x is now", sold1.x
sold1.targx = -2
sold1.advancex()
print "x is now", …
woooee 814 Nearly a Posting Maven

The direct inspiration for Labor Day occurred in New York City on Tuesday, September 6, 1882, when 10,000 workers left their jobs to parade through Manhattan demanding an eight-hour workday. The organizers called it "Artisans' Day" and encouraged workers in other cities to follow. The practice spread across the country within a few years.

woooee 814 Nearly a Posting Maven

Try splitting the original on the newline and working with the resulting list.
split_str=orig_string.split("\n")

woooee 814 Nearly a Posting Maven

What does happen? You don't know, so add a print statement to see what is happening

def main():
    List=[]
    infile = open ("words_dos.txt","r")
    words = infile.read()
    wordList=List.append(words)
    print "wordList =", wordList

Note the difference between read() and readlines() Click Here
Also, take a look at the "functions" heading Click Here for info on passing and returning values to/from a function.

woooee 814 Nearly a Posting Maven

Three of the first five presidents—John Adams, Thomas Jefferson, and James Monroe—died on July 4. Calvin Coolidge, on the other hand, was born on the Fourth, as was Malia Obama.

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
UpperCaseSentence = (myList[myString])

UpperCaseSentence is a tuple that only contains the final item in the list "myList", as you have written it, which is an empty string if the text that is entered ends with a period.

mySentenceList = mySentence.split('.')

Add some print statements and see for yourself. Also, as Gribouillis mentioned above, UpperCaseSentence can not be seen outside of the function in the code you posted.

woooee 814 Nearly a Posting Maven

If you have a <b> then you should also have a </b>, etc. Doing this yourself usually involves a split() and iterating over each item, and a good habit to form is to try to iterate over the text as few times as possible, which means looking for each tag in one pass over the string instead of a find and replace option which goes through the string however-many-tags-you-have times. Also, remember that you want a way to do this that you understand, so ignore any criticism from any self-appointed gods that frequent this forum.

def test_tags(tag):
    """ test each item from the list and return it untouched unless
        it starts with one of the "delete" tags
    """
    replace_these=['<b>', '</b>', '<p>', '</p>', '<h1>', '</h1>']
    for looking in replace_these:
        if tag.startswith(looking):
            return tag[len(looking):]     ## removed
    return tag  ## nothing found so save this tag

    ## or you can replace and return
    replace_these=[('<b>', 'rep_b'), 
                   ('</b>', 'rep_b2')]
    for looking, replacement in replace_these:
        if tag.startswith(looking):
            return replacement+tag[len(looking):]
    return tag  ## nothing found so save this tag



def tag_remove(HTML_string):
    """ split the string into a list on the "<" character and send
        each item to the test_tags() function for "cleaning"
    """
    clean_HTML = []
    HTML_list= HTML_string.split("<")
    for tag in HTML_list:
        return_ch = test_tags("<"+tag)
        if len(return_ch):
            clean_HTML.append(return_ch)
    return "".join(clean_HTML)

test_html="""<html>
    <head>
    <title>Should not be removed</title>
    </head>
    <b>bold test</b>
</html>
"""

print tag_remove(test_html)
woooee 814 Nearly a Posting Maven

When happy hour is a nap

woooee 814 Nearly a Posting Maven

In 1947, American computer engineer Howard Aiken said that just six electronic digital computers would satisfy the computing needs of the United States.

That may come true in our lifetime.

woooee 814 Nearly a Posting Maven

Spring Fever: Why You Feel Different With The Change In Season

Just as your bare legs are soaking in the sun, our brains are busy processing the bright light as well. The increased sunshine signals the body to produce less melatonin, which plays an important role in sleep.

"There's more daylight, so people have more energy, sleep a little less," Sanford Auerbach, M.D., director of the Sleep Disorders Center at Boston University, told Web MD.

With less melatonin pumping through your veins, you may also feel a lift in your mood and a more revved-up sex drive.

woooee 814 Nearly a Posting Maven

Dive Into Python covers all aspects, but if you are beginning there are other tutorials at the Python Wiki.

woooee 814 Nearly a Posting Maven

I am answering the question as asked. If that means that a I am not your robot then so much the better.

woooee 814 Nearly a Posting Maven

You have the range endings reversed and you want to start at +1 on the inner loop.

for x in range(0, len(a)-1):
    for j in range(x+1, len(a)):

Also you swap every time there is a difference instead of once per loop.

import random

a=[random.randint(1, 100) for ctr in range(20)]
print a
#
for x in range(0, len(a)-1):
    largest = x
    for y in range(x+1, len(a)):
        if a[largest] < a[y]:
            largest = y
    if largest > x:
        temp = a[largest]
        a[largest] = a[x]
        a[x] = temp
print a
woooee 814 Nearly a Posting Maven

Since it is a count, fetchone will not return anything. You could also fetchall, on a straight select, and check the length of the returned list if that is more straight forward.

woooee 814 Nearly a Posting Maven

You should test for whatever in the program, and if true then call the function or class in the imported module. As stated previously, this is a design problem not a programming problem. A simple example from you would help.

woooee 814 Nearly a Posting Maven

Doh, of course it is, which is why we always use a list.

testor = "rgb"
for x in ['r', '', 'g']:
    print x,
    if x in list(testor):
        print "is in"
    else:
        print "not"
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
if color in "rgb" and color != "":

if color is in "rgb" it can not be equal to "" or any other character, so this is redundant.

woooee 814 Nearly a Posting Maven

Your program works fine for me, after correcting some indentation errors, on Python2.7. Show us what the program prints.

def enter_names():
    fn=raw_input("please select your first name ")
    ln=raw_input("Please select your Last Name ")

    return fn, ln

def enter_numbers():
    fnbr=input("please select your favorite number ")
    sfnbr=input("please select your second favorite number ")

    return fnbr, sfnbr

loop=1
choice=0
while loop==1:
     print
     print "This program will add your first name to your last name, and then multiply your two favorite numbers in a select      order"
     print "Option 1: First name, Last Name, Numbers"
     print "Option 2: Numbers, First Name Last Name"
     print "Option 3: Exit"
     choice = int(raw_input("Choose your option: ").strip())
     if choice ==1:
          fn, ln = enter_names()
          fnbr, sfnbr = enter_numbers()
          print fn, ln
          print fnbr * sfnbr
     elif choice==2:
          fnbr, sfnbr = enter_numbers()
          fn, ln = enter_names()
          print fnbr * sfnbr
          print fn, ln
     elif choice == 3: 
        loop = 0

print "thank you"

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

You don't need two classes for this unless one person can have multiple addresses. You would store each class instance in a list and iterate through the list to find names: example

for instance in list_of_instances:
    if instance.firstName=="Bob":
        print instance.firstName, instance.lastName
        print instance.street, instance.city, instance.state
    else:
        print "Bob is not on file
woooee 814 Nearly a Posting Maven

Printed from the above code

-------------------------------------------------------------------------------

control name = Connors, Leah
club = Flying Club **
Connors, Frank ** Patterson, Shawn ** Patterson, John **

control name = Cosmo, Calvin
club = Sailing buddies ** Dodge ball group **
Patterson, Shawn ** Patterson, Sally **

final group ['Connors, Frank', 'Rowing school', 'Connors, Leah', 'Connors, Robert']

-------------------------------------------------------------------------------

An example of what the dictionary Person_to_friends would look like just using the first block would be
{'Leah Connors' : ['Frank Connors', Shawn Patterson, John Patterson']}

which would be the first and third lines that print in code posted above, after reversing the names.

The second dict Persons_to_networks would look like this {'Leah Connors' : ['Flying Club']}

which would be the first and second lines that print above.

I cant see how that builds a dictionary?

..

This should get you started but is not a complete solution as it is your homework.

This is my last post in this thread. The thread appears to have regressed into a "keep asking questions until someone codes it for you" thread.

woooee 814 Nearly a Posting Maven

I may have figured out what you mean. For future reference, you should post the input and what you expect the output to look like. This should get you started but is not a complete solution as it is your homework.

data="""Connors, Leah
 Flying Club
 Connors, Frank
 Patterson, Shawn
 Patterson, John

Cosmo, Calvin
 Sailing buddies
 Dodge ball group
 Patterson, Shawn
 Patterson, Sally

Connors, Frank
 Rowing school
 Connors, Leah
 Connors, Robert"""
#
f=data.split("\n")
#f = open('profiles.txt', 'r').readlines()
group=[]
for rec in f:
    rec = rec.strip()
    if len(rec):     ## not a blank record
        group.append(rec)
    else:
        names_list = []
        print "\ncontrol name =", group[0]
        print "club =        ", 
        for member in group[1:]:
            if "," not in member:       ## club name not person's name
                print member, "**",
            else:
                names_list.append(member)
        print
        for name in names_list:
            print name, "**",
        print
        group=[]     ## this group deleted
print "\nfinal group", group