Joelle Reynolds
Joelle Reynolds

Reputation: 11

Beginner error Python and Atom

Having trouble with Python code in Atom. I'm using 'Learn Python The Hard Way' to practice some coding. When I enter this code into Atom, there is no error but it just won't run (yes, I have Script installed and it works fine for other things). There is a little egg timer in the bottom of Atom but nothing else gives me any indication of what I may be doing wrong.

print "How old are you?",
age = raw_input()
print "How tall are you?",
height = raw_input()
print "How much do you weigh?",
weight = raw_input()

print "So, you're %r old, %r tall and %r heavy." % (
    age, height, weight)

When I type like this

print "How old are you?",
print "How tall are you?",
print "How much do you weigh?",

print "So, you're %r old, %r tall and %r heavy." % (
    age, height, weight)

The code runs, but with an error just saying that age is not defined and that makes sense because the code isn't complete. Does that just show that there is no problem with the editor but with the code? So please help. I'm new to this.

Upvotes: 1

Views: 491

Answers (2)

b107
b107

Reputation: 88

Try following

print "So, you're " + str(age) + " old, " + str(height) + " tall and " + str(weight) + " heavy."

Upvotes: -1

Dan Lowe
Dan Lowe

Reputation: 56727

The script package does not handle collecting input. If your script requires input (as your first script does), then it will just sit and wait.

Your second script doesn't expect any input, so it runs (but then, as you see, it has an error due to age not being defined).

The author of the script package has suggested (here and here) that Hydrogen may be an alternative if you need to handle input.

Upvotes: 2

Related Questions