Problem in import in python 3


I am using Python 3.6.5 where I typed this code,

import math

print math.sqrt(25)

But it shows an error,which tellls me that the syntax is wrong.
Any help will be appreciated.
Thank you


In Python 3, the way you use print changed.

In Python 2.x the following is fine:

print "Print this message"

The Codecademy Python course is based off Python 2, so you’ll be used to doing this. In Python 3, however, you need to do the following:

print("Print this message")

If you change your print statement to a function call as shown, it should work fine. :slight_smile:

Edit: I’m no good in the morning… (Cheers @stetim94)


function call, methods use dot notation.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.