Python Input function not Working in VS Code
Question:
balance = 100
print('Current Balance: ', balance)
while balance > 0:
print('1. WITHDRAW')
print('2. DEPOSIT')
choice = input("Select an option... ")
if (choice == 1):
print('1')
elif (choice == 2):
print('2')
else:
print('test')
When I run the code with the code runner extension the code shows in the terminal however when it gets to the input function it freezes like its asking me to input some data however I cant eve type a number or letter.
This is what the terminal shows…
[Running] python -u "c:UsersbowenDesktopCSE 120PROJECT 3main.py"
Current Balance: 100
1. WITHDRAW
2. DEPOSIT
Select an option...
Answers:
Code Runner shows results in OUTPUT and doesn’t accept inputs by default. Add
"code-runner.runInTerminal": true
in Settings.json, then you can input data.
the problem is not of python but of vscode, you have to enable one setting,
- do ctrl+, or just open settings
- search for code runner run in terminal
- enable it
balance = 100
print('Current Balance: ', balance)
while balance > 0:
print('1. WITHDRAW')
print('2. DEPOSIT')
choice = input("Select an option... ")
if (choice == 1):
print('1')
elif (choice == 2):
print('2')
else:
print('test')
When I run the code with the code runner extension the code shows in the terminal however when it gets to the input function it freezes like its asking me to input some data however I cant eve type a number or letter.
This is what the terminal shows…
[Running] python -u "c:UsersbowenDesktopCSE 120PROJECT 3main.py"
Current Balance: 100
1. WITHDRAW
2. DEPOSIT
Select an option...
Code Runner shows results in OUTPUT and doesn’t accept inputs by default. Add
"code-runner.runInTerminal": true
in Settings.json, then you can input data.
the problem is not of python but of vscode, you have to enable one setting,
- do ctrl+, or just open settings
- search for code runner run in terminal
- enable it