Str() issues


#1

<Below this line, add a link to the EXACT exercise that you are stuck at.>
Lesson #8 on the Strings & Console output section str()

<In what way does your code behave incorrectly? Include ALL error messages.>
I corrected the error message, however it will not let me move on.

“pi should equal the number 3.14–do not call str(pi) until after the print command on line 5!”

<What do you expect to happen instead?>
I expected to have it let me move on

```python

“”“Declare and assign your variable on line 4,
then call your method on line 5!”""

pi = "3.14"
print str(pi)

Thanks to whoever can help!

#2

Instruction:

Create a variable pi and set it to 3.14 on line 4.

but you set "3.14" .

we use "" for string.but you are told to add a float value.

The str() method turns non-strings into strings!
for example:

from 3.14 to "3.14"


#3

Thank you so much! However I am confused on the practical implications of this. Do you mind explaining?
Thanks!


#4

Two things:
First, “3.14” is already a string so you can’t turn it into a string again. Second, it wants you to set it to 3.14 to begin with. It would still come out the same when you print it though.


#5

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