This question already has answers here:
Can't send input to running program in Sublime Text
(5 answers)
Closed 6 years ago.
I'm trying to code a simple calculator using Python (2) in Sublime Text that consists of asking the user for the first number, the operation, then the second number. However, every time I try to execute the code in Sublime, I can't get past the first user input.
num1 = int(raw_input("Enter your first number:"))
operation = raw_input("Enter your operation:")
num2 = int(raw_input("Enter your second number:"))
This works in IDLE, i.e. I hit enter after I enter a number and it prompts for an operation. Is there a different way to do this in Sublime?
Sublime text doesn't support input from the console, it's just an out console, anyways there's a way around, you can use SublimeREPL.
You get a full IDLE like console embedded right into the sublime text!
Quotting what you get:
Launch python in local or remote(1) virtualenv.
Quickly run selected script or launch PDB.
Use SublimeText2 Python console with history and multiline input.
You can install it from package control(I guess you already have package control! If not get it from here).
Related
This question already has answers here:
Arrow keys not working while entering data for input() function
(2 answers)
Closed 7 months ago.
Problem :
Previously I wrote all of my python code on a Windows 10 machine, but more recently I've been trying to move over to MacOS. Everything is working just fine, with one exception. I'm writing a program that uses the python 'input' function and when pressing ↑ on MacOS it prints '^[[a' but on Windows 10 it prints the previous input. Is there get the previous input with the up arrow on Mac?
Example Code :
while True:
string = input()
print(string)
On Windows hitting ↑ will print the previous input but on Mac '^[[a' will print
Use readline module to provide reading and writing of history files. More info on that in the docs
import readline
while True:
string = input()
print(string)
This question already has answers here:
How to read multiple lines of raw input?
(16 answers)
Closed last year.
I wrote this code in Python3:
for _ in range(2):
inputs = input()
print(inputs)
It works fine when I provide the input values one by one.
It also works when the input values are copied and pasted as in Image 1 and the Image 2 is printed in the terminal.
However, when the input is copied and pasted as in Image 3, it just doesn't print the last line and expects the user to press enter (or to add more characters and then press enter) to finish the code: Image 4
What is going on?
Why is this happening and how can I solve it when some other program or a user gives the input that way?
There is no new line after the second input please provide new line (by hitting enter) .
After insert 1 10 there is no new line and input method is waiting for user to provide a new line so it will stop reading and return string as output.
This question already has answers here:
Can't send input to running program in Sublime Text
(5 answers)
How to Run Python Code on SublimeREPL
(4 answers)
Closed 1 year ago.
I've done everything to setup Python in Sublime Text 3.
When I execute my code, it displays the 1st line and then nothing else.
I can type after the 1st line but nothing happens.
This happens on every code I execute but i will provide my code and explain what it does
(code is on Croatian so dont mind the text)
Python version: 3.9.2
The code:
print('\n')
height = int(input("Unesi svoju visinu: "))
width = int(input("Unesi svoju debljinu: "))
BMI = width / (he/100)**2
if BMI<=18.4:
print("Ti se moraš udebljati!")
elif BMI<=24.9:
print("Dobar si!")
elif BMI<=29.9:
print("Malo se trebaš smršaviti!")
elif BMI<=34.9:
print("Trebaš se smršaviti!")
elif BMI<=39.9:
print("Trebaš se puno smršaviti!")
else:
print("Moraš odmah na treniranje!")
What the code does: It goes through the first input, when I type in the console to enter the input and I press enter, the code just stops executing.
VIDEO OF PROBLEM: https://youtu.be/ETsFJjw8O7s
A quick Google search leads you to this
discussion on the Sublime forum from 2018.
Sublime Text does not support inputting data into a program. You can up vote this feature request on: Currently you can try to install the package https://packagecontrol.io/packages/SublimeREPL and use it to run you program from a Sublime Text view. You you can try out the VSCode editor: https://github.com/Microsoft/vscode, which is pretty similar with Sublime Text.
I also cannot get user input to work, so presumably Sublime Text still does not support user input.
This question already has answers here:
Python, writing multi line code in IDLE
(7 answers)
Copy-paste into Python interactive interpreter and indentation
(9 answers)
Copying and pasting code into the Python interpreter
(11 answers)
Closed 2 years ago.
Just started learning.
Put the code:
username = input("Enter username:")
print("Username is: " + username)
into IDLE and after it asks for input, I expect it to print something. It doesn't. It just asks for input and that's it. What am I missing?
Just to clarify to everyone- I had entered the code on separate lines and it says
Enter Username:
I enter 'John'
Nothing happened after that.
Edit: I think the answer is that you cannot do multi-line code in the shell. I had no idea what a 'shell' is as opposed to a file where you can do multi-line.
Python is a top-down language, meaning that it will only continue to the next line of code until the current line of code has finished running
The input() function requires that you provide input into the console, to continue to the next line of code. So, you have to input something and only then will it actually print anything.
This question already has answers here:
Can't send input to running program in Sublime Text
(5 answers)
Closed 2 years ago.
I have python 3.7 installed and I have this code:
print("Enter your name:")
x = input()
print("Hello, " + x)
I was writing the name and press enter but the input is not over, it is still running and waiting for more inputs
Edit: the problem is that input is never ending, doesn't matter how many enters I press
Sublime text doesn't support inputting data. Read this : Sublime text input not working
That said, apparently SublimeREPL provides this sort of functionality, although I don’t use it myself so I don’t know much about it.