Python Forum
string to float conversion fails
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string to float conversion fails
#11
Your solution does not "work". It works for the case where the user presses enter without entering anything, but what if the user enters "a" or " "? It is not much more code to make a solution that works for any input string. In doing so you would learn about Python exception handling which is an important thing to know.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error could not convert string to float: deadendstreet 4 5,401 Oct-02-2019, 05:49 PM
Last Post: ichabod801
  ValueError: could not convert string to float: 'Pencil' Balakay97 3 5,921 Mar-08-2018, 07:30 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020