Why does this not work in Spyder


#1

This works in Codecademy but not in Spyder, a separate IDE


#2

Hi @elainalin,

If you are using Python 3, then print is a function, requiring parentheses. Instead of ...

print str(pi)

... you need ...

print(str(pi))

#3

Thank you! I also thought that for str(), it automatically adds the parentheses? But it doesn't print as "3.14"

So what makes 3.14 a string and not an integer then when it is printed?


#4

The str function performs that conversion. However, when a str is output, the quotes are not displayed.

Though the purpose of the conversion might not be obvious in this exercise, you will be able to observe in later exercises that it is sometimes useful to convert objects to a str type.


#5

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