Jul-12-2023, 11:16 AM
There is nothing wrong with the first program. It would work fine if you entered values when the program is run. This is me running your program.
The question is, why do you have "2" and "17" in you input prompts?
The input(prompt) function takes keyboard input from the user. It prints the prompt and waits for the user to press the enter key. Any keys typed before the enter key are accepted as input and returned by the function. If you don't type anything before pressing enter, the function returns an empty string (''). Your prompt makes it look like input was typed 2 or 17, but they do not provide any input. You have to type in the values when the program is running.
Output:(env)> python test.py
Please enter an integer value: 2 42
Please enter another integer value: 17 24
42 + 24 = 66
I entered 42 and 24, and the program printed the correct sum.The question is, why do you have "2" and "17" in you input prompts?
The input(prompt) function takes keyboard input from the user. It prints the prompt and waits for the user to press the enter key. Any keys typed before the enter key are accepted as input and returned by the function. If you don't type anything before pressing enter, the function returns an empty string (''). Your prompt makes it look like input was typed 2 or 17, but they do not provide any input. You have to type in the values when the program is running.