Need help with less .8 str()


#1

Hi,

I'm trying to complete the following however it returning an "Opps, try again"

The problem goes:

  1. Create a variable pi and set it to 3.14 on line 4.
  2. Call str(pi) on line 5, after print.

The code I created goes"

1 """Declare and assign your variable on line 4,
2 then call your method on line 5!"""
3
4 pi = "3.14"
5 print str(pi)

Can someone explain to me what I'm doing incorrectly? Any help would be greatly appreciated.

Thanks!


#2

I think I might have a similar issue. What's the error message??


#3

So following the instruction isn't working?

Meaning you have this code and it fails?

pi=3.14
print str(pi)

#4

Yea, after I input that exact code it fails, resulting with the error message below:

"Oops, try again. pi should equal the number 3.14--do not call str(pi) until after the print command on line 5"


#5

Don't put quotations around 3.14. That itself makes the text a string output. The str() function is making a number into text. See if that works.


#6

Thanks stevo! You were right. It was the quotations around 3.14 that was throwing me off. Below gave me the correct answer.

pi = 3.14
print str(pi)