View Single Post
Old 12-06-2012, 11:41 AM   #1
mykalberta
Franchise Player
 
mykalberta's Avatar
 
Join Date: Aug 2005
Location: Calgary
Exp:
Default Anyone know how to code Python?

I am trying to help my cuz who is taking it in an adv High School programming class. I have only ever taken Java and C++ so Python is sort of new to me and doesnt seem as structured

He has the following data in different text files: Calgary, Edmonton, etc

FNameLName community CommunityName (all on 1 line all in this same format)

JamesPuck community Evergreen
RobNewsome community Varsity

He wants to parse the list and get rid of the community placeholder so he can use the dictionary function to compare and count

People who live in Evergreen: JamesPuck, ...
Number of people who live in Evergreen: X
Number of peple who live in textfile_Calgary: X

We have got this far:

import text ('data.txt','r')
words=text.split() #words list
print(words)

This gets us a list: 'JamesPuck', 'community', 'Evergreen', 'RobNewsome', 'Community', 'Mulletville'

He wants to use dictionary but with community we cant seem to remove it from the list. If we can then we can simply compare Name to CommunityName

Any tips or help would be appreciated
__________________
MYK - Supports Arizona to democtratically pass laws for the state of Arizona
Rudy was the only hope in 08
2011 Election: Cons 40% - Nanos 38% Ekos 34%
mykalberta is offline   Reply With Quote