Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Issue converting to string to integer.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Fdama, post: 5096898"] Hi, I was following an exercise in a book when I edited the code and came across something I did not get. Here is the relevant part of the code that works: start=None #initialise while start !="": start=input("\nStart: ") if start: start=int(start) finish=int(input("Finish: ")) print("word[",start,":",finish,"] is", word[start:finish]) I then changed the code to this: start=None #initialise while start !="": start=int(input("\nStart: ")) if start: finish=int(input("Finish: ")) print("word[",start,":",finish,"] is", word[start:finish]) 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? Thanks [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Issue converting to string to integer.
Top