Link to home
Create AccountLog in
Avatar of William Peck
William PeckFlag for United States of America

asked on

newbie syntax question for Python - indenting

Looking at Python for the first time … going through these tutorials

I'm running Python via SPSS Statistics (Python 3.4.3 Shell) and got this error which is entered directly from the tutorial:
>>> x = int(input("Please enter an integer: "))
Please enter an integer: 55
>>> if x < 0:
	x = 0
	print('Negative changed to zero')
	elif x == 0:
		
SyntaxError: invalid syntax
>>> 

Open in new window


In Anaconda I get this error:
>>> x = int(input("Please enter an integer: "))
Please enter an integer: 55
>>> if x < 0:
... x = 0
  File "<stdin>", line 2
    x = 0
    ^
IndentationError: expected an indented block
>>>

Open in new window

And if I press the Indent key, Anancoda throws up on me ...

So not sure what I'm doing wrong right out of the gate ...

Also, is there a recommended IDE for Python?
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of William Peck

ASKER

aikimark,

thanks! Yes, I figured out about spacing and not tabs … but thanks, especially for the coding/IDE tips.