11

I'm required to covert the variable:

pi_string = "3.1415926"

into a float. Here's what I'm dealing with:

screenshot

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
itzRafay
  • 149
  • 1
  • 1
  • 6

2 Answers2

18

Your line should be pi_float = float(pi_string)

float(pi_string) is a float value, you can not assign to it, because it is not a variable.

Dean Fenster
  • 2,345
  • 1
  • 18
  • 27
5

The method float() will do this for you if pi_string = "3.1415926".

>>>pi_float = float(pi_string)
>>>type(pi_float)
<class 'float'>
Clíodhna
  • 818
  • 1
  • 15
  • 29