Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6122 > unrolled thread

Re: NEED HELP- read file contents, while loop to accept user input, and enter to exit

Started byChris Angelico <rosuav@gmail.com>
First post2011-05-24 18:46 +1000
Last post2011-05-24 18:46 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: NEED HELP- read file contents, while loop to accept user input, and enter to exit Chris Angelico <rosuav@gmail.com> - 2011-05-24 18:46 +1000

#6122 — Re: NEED HELP- read file contents, while loop to accept user input, and enter to exit

FromChris Angelico <rosuav@gmail.com>
Date2011-05-24 18:46 +1000
SubjectRe: NEED HELP- read file contents, while loop to accept user input, and enter to exit
Message-ID<mailman.2006.1306226795.9059.python-list@python.org>
On Tue, May 24, 2011 at 6:31 PM, Cathy James <nambo4jb@gmail.com> wrote:
>     s = input ('enter name: ').strip()

Are you using Python 2 or Python 3? If it's Python 2, this should be
raw_input().

>     f = open ('c:/testing.txt', 'a')
> ...
>         f = open ('c:/testing.txt', 'r')

You may be having trouble here as a result of not closing the file and
then trying to reopen it.

Also, at some point you have to check if 's' (the user's inputted
string) is empty. You can then leave the loop using the 'break'
statement.

Hope that helps! Best of luck with your homework.

Chris Angelico

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web