Thank you for help Steven! I intend to correct it. But also I would like to know if I wrote the correctly in order to the output that I'm looking for?
On Oct 20, 2013, at 19:22, "Sammy Cornet" <[email protected]> wrote: > Hello! > > I'm using python 2.7.5 version and I'm trying to write a program related to a > file named unsorted_fruits.txt contains a list of 26 fruits, each one with a > name that begins with a different letter of the alphabet. My program's goal > is to read in the fruits from the file unsorted_fruits.txt and writes them > out in alphabetical order to a file named sorted_fruits.txt while I'm using > while loop > > For this assignment you must incorporate the use of a list, for loop and / or > while loop. > > so here is what I have on my script: > > > > infile = open('Desktop/unsorted_fruits.docx' ,"r") > > outfile = open('Desktop/sorted_fruits.docx', 'w') > > > > def find(): > > index = 0 > > while index < 26: > > list < 26 > > list = ["a", "b", "c", "e", "f", "g", "h", "i", "j", "k", "l", "m", > "n" "o", "p", "q", "r", "s", "t", "u", "v", "w", "z", "y", "z"] > > if index[0] == list[0]: > > infile = list + 1 > > print infile > > index += 1 > > infile.close() > > outfile.close() > > > And here is my output: > > Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on > win32 > Type "copyright", "credits" or "license()" for more information. > >>> ================================ RESTART ================================ > >>> > > Traceback (most recent call last): > File "F:/7.real.py", line 1, in <module> > infile = open('Desktop/unsorted_fruits.docx' ,"r") > IOError: [Errno 2] No such file or directory: 'Desktop/unsorted_fruits.docx' > >>> > > > I'm not sure if I write the program correctly, but I can't get my file wich > is on my desktop to the program. CAn someone help me please? > > > > > > _______________________________________________ > Tutor maillist - [email protected] > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
