User Profile
Collapse
-
It did not give an error message! It ran the program correctly and printed to the screen correctly but it didnt write it to the outfile! -
Why won't this write to an outfile?
Here is my code:
...Code:def calcaverage (grades): return float(sum(grades)/len(grades)) #def findHighest(grades): sort(grades) return grades[-1] #def findLowest(grades): sort(grades) return grades[0] #def findLongestName(names): pass infile = open("names.txt", "r") names = [] grades = [] is_name = True individual_grades -
how do I sort a list of names?
I need to sort a list of first and last names from shortest to longest.
for example:
[John Doe, Jane Smith, Jane Doe]
I have to write a function to find the longest name but noe sure how to do it! -
We are supposed to start with 4 which is the longest character and work back to 1.Leave a comment:
-
How to write a program to decode a message?
My program needs to fix an encrypted text file. The person who wrote it put it in “leet speak”, with special characters representing various letters. For example, consider the sample below:
1 4|-| 50 |_33+.
is really
I am so leet.
Here is the conversion table I need to use.
A 4
B 8
C [
D |)
E 3
F |#
G 6
H #
I 1
J ]
K |\
... -
Here is how i changed it:
...Code:scores = [] names = [] averagescore = [] infile = open("bowlingscores.txt", "r") for i, line in enumerate(infile): if i % 2 == 1: scores.append(int(line)) else: names.append(line) average = float(sum(scores) / len(scores)) print(average) print (names) print (scores) outfile = open("averages.txt",Leave a comment:
-
Where in my code would it go?
Also how do I make it go through my loop every time? It is only going through once.Leave a comment:
-
How do I strip a new line?
It only catches the comparison to average for the first name and i need to strip the new line.
Can you help?
...Code:scores = [] names = [] infile = open("bowlingscores.txt", "r") for i, line in enumerate(infile): if i % 2 == 1: scores.append(int(line)) else: names.append(line) average = float(sum(scores) / len(scores)) print (names) -
I got the file to open but not sure how to seperate it to average the score but still keep them together to print them outLeave a comment:
-
How do i work with infiles and outfiles
Here is my probleb but I dont know where to start. I kow how to create the txt file but i dont know how to read from it and output it. Iknow this is a homework assignment and i am not looking for the answer. I just need someone to help me get started.
Write a program that will read an unknown number of bowlers and their bowling scores (with possible values from 1 to 300) from an external file called "bowlingscores. txt".... -
-
Now it is not printing my menu. How do I call that function?
line 14Leave a comment:
-
Thank you so much I have been going over and over the code and didnt see the ) on line 19.
The only thing it said was syntax error and it was showing line 20.Leave a comment:
-
Why am I getting a syntax error
This is giving me a syntax error at the elif statement but i'm not sure why. please help me.
...Code:miles = 0.0 kilometers = 0.0 def show_menu(): print("1. Convert miles into kilometers.") print("2. Convert kilometers into miles.") print("3. Exit") def convert_miles_to_kilometers(miles): miles* 1.609 return kilometers def convert_kilometers_to_miles(kilometers): -
Here is what i have:
...Code:fn1 = raw_input("What is the name of the first file (be sure to include .txt after the filename)?") fn2 = raw_input("What is the name of the second file (be sure to include .txt after the filename)?") fileobj1 = open("fn1", "r") fileobj2 = open("fn2", "r") if file1 == file2: print ("Yes these files are theLeave a comment:
-
-
The way i have it it says no such file or directory on line 4. How do i fix it?Leave a comment:
-
This is what i have, but it won't run right.
Code:file1 = raw_input("What is the name of the first sile including the .txt?") file2 = raw_input("what is the name of the second file including the .txt?") file1 = open("file1" , "r") file2 = open("file2", "r") if file1 == file2: print("Yes") else: print("No")Leave a comment:
-
to open the file is what you have the same as:
infile = open ("filename" , "r")Leave a comment:
-
I actually got that far on my own but thanks anyways. Can you help me figure out how to make it print the first line in each file that is different?Leave a comment:
No activity results to display
Show More
Leave a comment: