Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: Homework Help: Python Function
12-04-2013, 03:38 AM #1
- Join Date
- Dec 2013
- Thanked 0 Times in 0 Posts
Homework Help: Python Function
As the title says, I need help with my homework. So I have to create a program that will: open a file that consists of different sets of three numbers, and then output the smallest number for each line. (Note: I'm not allowed to use the min() function!!)
The program would output:
I was wondering if anyone could check my code and see what's wrong with it, because it doesn't seem to be getting the smallest number?
def smallest(*lowest): small_numbers = [lowest] small_numbers.sort() def main(): input_file = open("datanums.txt", "r") number_file = input_file.readlines() smallest(number_file) for i in range(len(number_file)): print number_file[i] main()