Avatar of William Peck
William Peck
Flag 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?
Python

Avatar of undefined
Last Comment
William Peck

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
aikimark

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
William Peck

ASKER
aikimark,

thanks! Yes, I figured out about spacing and not tabs … but thanks, especially for the coding/IDE tips.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23