Thanks for all the help everyone! After I manually edited the txt file, this is
what I came up with:
car_dict = {}
car_file = open('cars.txt', 'r')
for line in car_file:
temp = line.strip().split(None, 2)
temp2 = line.strip().split('\t')
if len(temp)==3:
year,
On Sunday, March 31, 2013 12:38:56 PM UTC-4, Roy Smith wrote:
> In article ,
>
> "C.T." wrote:
>
>
>
> > Hello,
>
> >
>
> > I'm currently working on a homework problem that requires me to create a
>
> > dictiona
On Sunday, March 31, 2013 12:06:18 PM UTC-4, Chris Angelico wrote:
> On Mon, Apr 1, 2013 at 2:52 AM, C.T.
>
> > After playing around with the code, I came up with the following code to
> > get everything into a list:
>
> >
>
> > d=[]
>
> > car_file
On Sunday, March 31, 2013 12:20:25 PM UTC-4, zipher wrote:
> Every line is now an element in list d. The question I have now is how can I
> make a dictionary out of the list d with the car manufacturer as the key and
> a tuple containing the year and the model should be the key's value. Here is
Hello,
I'm currently working on a homework problem that requires me to create a
dictionary from a .txt file that contains some of the worst cars ever made. The
file looks something like this:
1958 MGA Twin Cam
1958 Zunndapp Janus
1961 Amphicar
1961 Corvair
1966 Peel Trident
1970 AMC Gremlin
197
Hello,
Currently doing a project for class an I'm stuck. I have a csv file that I'm
suppose to extract some information from. I've created a function that ignores
the first six lines of the csv file and creates a list of values in a
particular column. Here is the code:
def get_values(file, in