-3

I am using Sublime Text 3. This is my code:

a = raw_input("Test raw: ")

It correctly asks for Test raw: but does not do anything after entering a letter. This line, however, works in command prompt.

Basically, after Test raw: displays and I enter a character, I want it to move on the next line. Right now, it does not. I can just keep entering characters without it moving on.

Edit: SublimeREPL is for Sublime Text 2. I could not install it for Sublime Text 3. Is there something similar?

Answer: Use this website to install package control and follow the rest of the instructions here. Thanks everyone!

Shivani
  • 105
  • 1
  • 9

1 Answers1

0

In the command prompt (use known as the Python REPL, for "read evaluate print loop"), if an expression is left hanging, its representation will be printed after evaluation finishes - hence the "read, evaluate print, loop".

That's not true of a Python program. In the Python program, the input is assigned to a, then the program finishes. To make it print, do:

a = raw_input("Test raw: ")
print(a)

Or simply

print(raw_input("Test raw: "))

To skip using the variable altogether

James
  • 2,843
  • 1
  • 14
  • 24
  • Thanks. However, it does not move on to the next line. For example, if the code is "a = raw_input("Test raw: ") print 'b'", it never prints 'b' even after entering something for Test raw: – Shivani Jul 28 '16 at 17:25
  • 1
    Well, for starters, b will be undefined so it will error out there, and also it won't move onto the next line until it receives input. – James Jul 28 '16 at 17:26
  • 1
    Even after I put in input though, it does not move on. Also it is 'b', not a variable b – Shivani Jul 28 '16 at 17:30
  • `a = raw_input(whatever)` won't print the value of `a` in the REPL either. The REPL only prints the value of expression statements, and this is an assignment statement. – user2357112 Jul 28 '16 at 17:40
  • From your question, it looks like James' answer correctly answers the question. However, from your reply, it seems that is not what you are trying to accomplish. Maybe we can assist better with a little more detail for what you are trying to achieve. For example, do you want to have a continue receiving input and then print all data given? – jameswassinger Jul 28 '16 at 17:41
  • Ok, more specifically my question is about moving on after this line. It does not need to print the output but it does not need to end at some point. Even after I enter a letter and hit 'Enter', it does not end. It simply allows you to keep entering input. – Shivani Jul 28 '16 at 17:51