python code visual studio code issue
Posted by m__khn@reddit | Python | View on Reddit | 19 comments
Help in solving my issue? In VScode issue is happening bcs there is an input repetition and its not running without debugging.
a = input("Enter number 1: ") b = input("Enter number 2: ")
print("Number a is: ", a) print("Number b is: ", b)
Python-ModTeam@reddit
Hi there, from the /r/Python mods.
We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython or for the r/Python discord: https://discord.gg/python.
The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here.
On /r/LearnPython the community and the r/Python discord are actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. No matter what level of question you have, if you are looking for help with Python, you should get good answers. Make sure to check out the rules for both places.
Warm regards, and best of luck with your Pythoneering!
Spidey_qbz@reddit
Could you send the error that you have received. The provided code is fine .
m__khn@reddit (OP)
I cant attach the image here actually when im giving input in terminal its repeating instead of asking for number 2
DuckOfficial@reddit
Are you mashing enter for the first input and not receiving the second print?
That means you are sending python breaklines instead of signaling it you finished your input.
Think about it as "enter" having two roles: - Going down a line - this is a line break. - Signaling you finished your input.
This is probably the issue because you claim it works in debug, but not the terminal. Make sure you are using the vscode terminal, press ctrl+LShift+tilda(the button under escape) This should launch it, if you have any more trouble check chat gpt or something
iknowsomeguy@reddit
Is this your code?
m__khn@reddit (OP)
Yes
DuckOfficial@reddit
That code looks perfectly fine, where and how are you running your code?
m__khn@reddit (OP)
Im running on vs code but in terminal numbers repeating only working when im debug running
DuckOfficial@reddit
Are you using an extension that adds a button to execute code? To execute code on a fresh install of vscode you must use the terminal with
iknowsomeguy@reddit
Is it part of a larger block or are you trying to run it alone?
m__khn@reddit (OP)
Its a single prog im running in vscode
Pristine-Sir-1552@reddit
add string in the print
m__khn@reddit (OP)
"" is already a str ig
edcculus@reddit
Looks like you should use f strings for your print statement-
print(f”Number a is: {a}, and Number b is: {b}”)
iknowsomeguy@reddit
OPs print statements should work fine, if they are on separate lines. Formatted strings are probably a better way to go from a readability perspective in more complicated code, though.
edcculus@reddit
Oh yea I didn’t see the two separate print statements or realize they were on separate lines.
abentofreire@reddit
It sounds like you have multiple statements in the same line using a space separation. It's hard to tell without proper formatting. Try having one statement only per line
m__khn@reddit (OP)
Actually in vs code i did in different separate line but still repetition issue is coming in terminal im typing any number but its repeating only
abentofreire@reddit
When you post your code on reddit r/python there is an icon for code block. if you write your post with proper code formatting makes much easier to help out.