Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noted an issue while using input() #118637

Closed
chandra122 opened this issue May 6, 2024 · 2 comments
Closed

Noted an issue while using input() #118637

chandra122 opened this issue May 6, 2024 · 2 comments

Comments

@chandra122
Copy link

chandra122 commented May 6, 2024

Bug report

Bug description:

Version used: python3.10 with venv -
PythonPractice

value = int(input())
# Trying to pass an integer value from command prompt ex: 4 throws

Traceback (most recent call last):
  File "D:\PythonPractice\Algorithms And Data Structures\linearsearchexamples.py", line 13, in <module>
    value = int(input().strip())
            ^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''

CPython versions tested on:

3.10

Operating systems tested on:

Windows

@chandra122 chandra122 added the type-bug An unexpected behavior, bug, or error label May 6, 2024
@Eclips4
Copy link
Member

Eclips4 commented May 6, 2024

Hello! This repository is intended as CPython bug tracker.
Ask for help here, please: https://discuss.python.org/c/users/7

@Eclips4 Eclips4 closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2024
@Eclips4 Eclips4 removed the type-bug An unexpected behavior, bug, or error label May 6, 2024
@terryjreedy
Copy link
Member

I had to reformat your post to link to the image, but:

  1. The code shown in the image is different from the code shown in the text, with the addition of '.strip().
  2. That addition does not matter, as both value error lines show the input as being '', regardless of what image shows above the image of the traceback.
  3. for that input, the error is correct.

On Windows with 3.13.0a6:

>>> value = int(input())
4
>>> value
4
>>> value = int(input())

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    value = int(input())
ValueError: invalid literal for int() with base 10: ''

I got the above interactively with both IDLE and interactive Python. I also made file with

value = int(input('1>'))
print(value)
value = int(input('2>'))

with result

1>4
4
2>
Traceback (most recent call last):
  File "F:\dev\tem\tem3.py", line 3, in <module>
    value = int(input('2>'))
ValueError: invalid literal for int() with base 10: ''

Note that different prompts make it clear what was entered in response to each input() request.

There is no demonstrated reproducible bug on current Python. Whatever happens with the foreign IDE is beyond our control. You need to show an error running standard Python in Command Prompt with distinct prompts as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants