<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>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?<br><br><br></div><div><br>On Oct 20, 2013, at 19:22, "Sammy Cornet" <<a href="mailto:corsam28@hotmail.com">corsam28@hotmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
<div dir="ltr"><p class="MsoNormal" style="margin-bottom: 12pt; line-height: 14.4pt; background-position: initial initial; background-repeat: initial initial;"><span style="font-family: Arial, sans-serif;">Hello!</span></p><p class="MsoNormal" style="margin-bottom: 12pt; line-height: 14.4pt; background-position: initial initial; background-repeat: initial initial;"><span style="font-family: Arial, sans-serif;">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</span><span style="font-family: Arial, sans-serif; line-height: 14.4pt; font-size: 12pt;"> 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</span></p>
<p class="MsoNormal" style="margin-bottom: 12pt; line-height: 14.4pt; background-position: initial initial; background-repeat: initial initial;"><span style="font-family: Arial, sans-serif;">For
this assignment you must incorporate the use of a list, for loop and / or while
loop.<o:p></o:p></span></p><p class="MsoNormal" style="margin-bottom: 12pt; line-height: 14.4pt; background-position: initial initial; background-repeat: initial initial;"><span style="font-family: Arial, sans-serif;">so here is what I have on my script:</span></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"><br></span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;">infile = open('Desktop/unsorted_fruits.docx' ,"r")</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;">outfile = open('Desktop/sorted_fruits.docx', 'w')</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"><br></span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;">def find():</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"> index = 0</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"> while index < 26:</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"> list < 26</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"> 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"]</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"> if index[0] == list[0]:</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"> infile = list + 1</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"> print infile</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"> index += 1</span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"> infile.close() </span></font></p><p class="MsoNormal" style="margin-bottom: 12pt;"></p><p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial, sans-serif"><span style="line-height: 19.1875px;"> outfile.close() </span></font></p><div><br></div><div>And here is my output:</div><div><br></div><div><div>Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32</div><div>Type "copyright", "credits" or "license()" for more information.</div><div>>>> ================================ RESTART ================================</div><div>>>> </div><div><br></div><div>Traceback (most recent call last):</div><div> File "F:/7.real.py", line 1, in <module></div><div> infile = open('Desktop/unsorted_fruits.docx' ,"r")</div><div>IOError: [Errno 2] No such file or directory: 'Desktop/unsorted_fruits.docx'</div><div>>>> </div></div><div><br></div><div><br></div><div>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?</div>
<p class="MsoNormal" style="margin-bottom: 12pt; line-height: 14.4pt; background-position: initial initial; background-repeat: initial initial;"><br></p>
<p class="MsoNormal" style="line-height: 14.4pt; background-position: initial initial; background-repeat: initial initial;"><span style="font-family:"Arial","sans-serif";mso-fareast-font-family:"Times New Roman";
color:blue;mso-font-kerning:0pt;mso-fareast-language:FR"><br>
<!--[if !supportLineBreakNewLine]--><br>
<!--[endif]--></span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></p> </div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a></span><br><span>To unsubscribe or change subscription options:</span><br><span><a href="https://mail.python.org/mailman/listinfo/tutor">https://mail.python.org/mailman/listinfo/tutor</a></span><br></div></blockquote></body></html>