r/pythonhelp • u/jamesfarted09 • Dec 03 '20
Python Syntax Errors
Hi!
I was practicing some pretty easy scripts and all it does is see what a number is and print 'big' or 'small'. so can anyone tell me what the problem is?
x = 5
if x = 5 :
print('big')
if x = 1 :
print('small')
print('done!')
Also im using Pyscripter as an IDE
2
Upvotes
1
u/MT1961 Dec 04 '20
Let's look at what you meant, then see what went wrong:
x = 5
if x == 5 : print('big')
if x == 1 : print('small')
print('done!')
Note, first, that as others have pointed out, you need to indent all Python blocks. Alternatively, you can put it on one line if it is a single statement, as I've done above. Second, as someone else pointed out, you need == for comparing numbers, while = is an assignment. Finally, you can write this a lot more easily:
x = 5
if x == 5 : print('big') elif x == 1 : print('small')
print('done!')