Python Forum
Code error from Fundamentals of Python Programming van Richard L. Halterman - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Code error from Fundamentals of Python Programming van Richard L. Halterman (/thread-40329.html)

Pages: 1 2


RE: Code error from Fundamentals of Python Programming van Richard L. Halterman - Skaperen - Jul-13-2023

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>



RE: Code error from Fundamentals of Python Programming van Richard L. Halterman - Heidi - Jul-20-2023

Thank you,

I did it wrong, now i understand

With kind regard
Heidi


RE: Code error from Fundamentals of Python Programming van Richard L. Halterman - Skaperen - Jul-25-2023

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.