Python Forum

Full Version: Code error from Fundamentals of Python Programming van Richard L. Halterman
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
this is what it did for me:
Output:
lt1a/forums/2 /home/forums 6> box try.py +----<try.py>------------------------------------+ | x = input('Please enter an integer value: 2 ') | | y = input('Please enter an integer value: 7 ') | | num1 = int(x) | | num2 = int(y) | | print(num1, '+', num2, '=', num1 + num2) | +------------------------------------------------+ lt1a/forums/2 /home/forums 7> py try.py Please enter an integer value: 2 2 Please enter an integer value: 7 7 2 + 7 = 9 lt1a/forums/2 /home/forums 8>
Thank you,

I did it wrong, now i understand

With kind regard
Heidi
simple explanation for others:

if you type just the Return key only, you get an empty string. input() does not get a number from the end of the output.

YOUR CODE needs to check for an empty string and substitute the default input, if that is you intention.
Pages: 1 2