Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46748
| From | Dan Sommers <dan@tombstonezero.net> |
|---|---|
| Subject | Re: Issue converting to string to integer. |
| Newsgroups | comp.lang.python |
| References | <55c2eb06-7b9f-480f-8668-5e19e236799f@googlegroups.com> |
| Message-ID | <DFSqt.45780$CG1.40950@newsfe21.iad> (permalink) |
| Organization | TeraNews.com |
| Date | 2013-06-03 01:52 +0000 |
On Sun, 02 Jun 2013 18:12:33 -0700, Fdama wrote:
> I combined the int conversion and the input on the same line, rather
> than to have two different statements. But got an error message:
> Traceback (most recent call last):
> File "C:\Users\Faisal\Documents\python\pizza_slicer.py", line 23, in <module>
> start=int(input("\nStart: "))
> ValueError: invalid literal for int() with base 10: ''
>
> Could someone tell me why I got this error message?
The difference is what used to happen in between the input and the
conversion. In the first version, the "if" statement prevents the
conversion from happening when there is no input. In the second
version, though, python tries to do the conversion with no input, and
fails.
Dan
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Issue converting to string to integer. Fdama <fsdama@gmail.com> - 2013-06-02 18:12 -0700
Re: Issue converting to string to integer. Dan Stromberg <drsalists@gmail.com> - 2013-06-02 18:44 -0700
Re: Issue converting to string to integer. Dan Sommers <dan@tombstonezero.net> - 2013-06-03 01:52 +0000
Re: Issue converting to string to integer. Chris Angelico <rosuav@gmail.com> - 2013-06-03 12:08 +1000
Re: Issue converting to string to integer. alex23 <wuwei23@gmail.com> - 2013-06-02 19:02 -0700
csiph-web