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.
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:
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:
How to clear the interpreter console?
(31 answers)
Closed 2 years ago.
I have been making a 5 question "Quiz" on Python. It is pretty simple in code design since I do not have much experience. I want to hide the previous questions so that the code is easier on the eyes and user friendly. I work on IDLE by the way.
i="Incorrect, You lost points for this question."
i2="Incorrect, Try Again."
g="Good Job!"
x=100 #percentage
q1=input("What is 2+3? ")
while q1 != "5":
x-=20
print (i,"Your current score:",x,"%")
q1=input("What is 2+3? ")
while q1 != "5" and (x<100):
print (i2)
q1=input("What is 2+3? ")
else:
print(g)
print("Your current score:",x,"%")
Q2=input("What are the first 3 digits of Pi? ")...
This goes on 4 more times. I want all text that I displayed for q1 to disappear when the input value for Q2 appears.
Import the module os
import os
os.system('cls')
os.system('cls') will clear the screen on windows otherwise replace 'cls' with 'clear'
Just put tthat line whenever you want to clear everything on your code
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).