Explicit string conversation


Whenever I do the code it says, This comes up:

File "python", line 3
print "The value of pi is around " str(2)" + 3.14
SyntaxError: invalid syntax

This is my code:

Turn 3.14 into a string on line 3!

print "The value of pi is around " str(2)" + 3.14

What did I do wrong?:confused:


Ok well putting a 2 into str() will give you a 2 in quotes plus 3.14. So you would end up getting 5.14 if the addition is carried out. Lets look at this in a simpler manner.
1.) Create a variable pi and set it to 3.14 on line 4. So pi = 3.14
2.) Call str(pi) on line 5, after print. So print str(pi).
Sometimes being creative is very good! But in other times like here I would suggest first doing what the instructions point out then go back and add the cool stuff :thumbsup: :smile:


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