# Problem with Python Shell



## ankurankan (May 13, 2011)

Whenever i use the print statement it returns a syntax error.What should I do?


Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> print 52*4
SyntaxError: invalid syntax
>>> print 52
SyntaxError: invalid syntax
>>> a=32
>>> print a
SyntaxError: invalid syntax
>>> print '12'
SyntaxError: invalid syntax
>>> if (a<b):
	print 'b is greater'

SyntaxError: invalid syntax


----------



## krishnandu.sarkar (May 13, 2011)

print() is a function.

So...
print(52*4)

print(52)

a=32
print(a)

print('12')

if(a<b):
     print("B is greater")

BTW you can use python as calculator without print too..
*img218.imageshack.us/img218/9808/pythonm.jpg

Uploaded with ImageShack.us


Anyway...Read Docs carefully again..!! *docs.python.org/py3k/tutorial/introduction.html


----------



## ankurankan (May 13, 2011)

thanks....


----------



## krishnandu.sarkar (May 14, 2011)

You are welcome 

Happy Coding


----------



## umeshtangnu (May 14, 2011)

you are using python 3.x shell but your syntax is of 2.x series


----------



## ankurankan (May 17, 2011)

Now I am having problem with the else statement


>>> x=21
>>> if x%2==0:
	print (x ,"is even")
	else:

SyntaxError: invalid syntax
>>>


----------



## krishnandu.sarkar (May 17, 2011)

```
x = 21
if(x%2 == 0):
      print("Even")
else:
      print("Odd")
```

Again, I highly suggest you to read the docs. Or find some ebook or get a book.

*img841.imageshack.us/img841/4760/pythonz.jpg

Uploaded with ImageShack.us


----------



## Liverpool_fan (May 17, 2011)

ankurankan said:


> Now I am having problem with the else statement
> 
> 
> >>> x=21
> ...



Indention mate, make sure the print statement is indented by spaces as compared to your if and else is indented to match the indention of the if statement.


----------



## krishnandu.sarkar (May 17, 2011)

^^Yup, and his if syntax is also wrong.


----------



## abhijangda (May 18, 2011)

run IDLE, python shell in it will automatically indent the statements.


----------

