-2
x = (2, 3, 4)    

a, b, c = x
    
d, e, f = float(a, b, c)
    
print(d)

This gives an error. Is it possible to change multiple integers to floats?

F21
  • 21
  • 3
  • 3
    You don't have a list of integers anywhere in your code. – Pranav Hosangadi Mar 22 '21 at 14:00
  • Does this answer your question? [In Python, how do I convert all of the items in a list to floats?](https://stackoverflow.com/q/1614236/2745495) – Gino Mempin Mar 22 '21 at 14:03
  • Documented here: ``` https://docs.python.org/3/library/functions.html#float ```` Says that float() only takes a number or string ``` Return a floating point number constructed from a number or string x. ``` – Noah Mar 22 '21 at 14:04
  • The variables a,b and c are integers, but they are not defined as a list. `list_ints = [2,3,4]` or `list_ints = [a,b,c]` would work. Converting that in a oneliner would be `list_ints = [float(x) for x in list_ints]` – Mitchell van Zuylen Mar 22 '21 at 14:17

1 Answers1

1
a, b, c = map(float, (a, b, c))
dukkee
  • 1,112
  • 1
  • 9
  • 17