Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55090
| References | <380132bc-bc9c-4d57-95d8-dc01f26f47a5@googlegroups.com> |
|---|---|
| Date | 2013-10-01 03:07 +1000 |
| Subject | Re: VERY BASIC HELP |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.495.1380560866.18130.python-list@python.org> (permalink) |
On Tue, Oct 1, 2013 at 2:55 AM, <vignesh.harikrishna@gmail.com> wrote:
> print "Invalid input.";raw_input("Press <enter> to close this window");exit
> 1. Even if c is not 2 or 3, the program continues, as if it received a valid input, it does not exit as I have tried to code it to.
In Python, exit isn't a statement, it's a function. So you need to write:
exit()
to actually terminate.
> elif p==3 and c==3:
> print "The result is :";x+y+z
> 2. If all values are entered correctly, the result does not display. It shows up as "The result is :" and just blank.
The semicolon ends the print statement, and then you simply evaluate
and do nothing with the sum. Try a comma instead - that'll make it a
second argument to print, so it'll be printed out as you expect.
Thank you for making your problem so clear. You've given your code,
and you've said exactly what it's doing that you don't expect. I
really appreciate that! But one thing I would ask: Next time, please
consider your subject line. That's the first chance you have to grab
someone's attention - "VERY BASIC HELP" doesn't say _what_ you need
help with. :) Your post makes a nice change from some I've seen,
though...
Have fun, happy Pythoning!
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
VERY BASIC HELP vignesh.harikrishna@gmail.com - 2013-09-30 09:55 -0700
Re: VERY BASIC HELP Chris Angelico <rosuav@gmail.com> - 2013-10-01 03:07 +1000
Re: VERY BASIC HELP John Gordon <gordon@panix.com> - 2013-09-30 17:25 +0000
Re: VERY BASIC HELP vignesh.harikrishna@gmail.com - 2013-09-30 10:50 -0700
Re: VERY BASIC HELP Joel Goldstick <joel.goldstick@gmail.com> - 2013-09-30 15:02 -0400
Re: VERY BASIC HELP rusi <rustompmody@gmail.com> - 2013-10-01 10:12 -0700
Re: VERY BASIC HELP Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-01 18:25 +0100
csiph-web