How to stop python executing halfway


Hi guys, codeacademy has taught us to run our code in this manner:

original = raw_input("enter a word:")
if len(original)>0:
    print original
    print "empty"

However, when i enter into my downloaded python, it immediately asks me to input the word before I can even key in my "if" statement. Is there anyway for me to delay this until I finish writing my entire code?

As of now, the only way i managed to work over this is by using this code instead:

def original(word):
	if len(word)>0:
		print word
		print "empty"

original(raw_input("enter a word:"))

Is there anyway I can get python to not execute my whole code until Im done with it? Ive been stuck for an hour reading forums but cant find an answer ):


That last example would indicate a necessary do-over. Save what you have off to the side and start over.That means go back to the beginning and be sure you understand the instructions. This may sound crass, but it really is well intentioned.


Im sorry, but Im not quite clear on your instruction. Let me rephrase my question,

the code above works on python on codeacademy, however, when using on my own python, it does not work because python prompts me to input immediately before i can even key in my "if" function


It sounds like you are trying to use the interactive console (shell). Write your code in a New File that you saved, then Run it.


Ohhhh okay so I shouldnt be using shell?? Then where should i be writing my code in for this new file? From my python folder there is only Python(command line) and IDLE.



NP. Just go to, File > New File.

Then code your heart out. If you are versioning be sure to save as separate files.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.