Python Forum
string to float conversion fails
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string to float conversion fails
#1
Python version: 3.12
Windows 10, x64

This the problematic raw:

---------------------------------------------------------------
a = float(input("Vnesi ja osnovata a = "))
---------------------------------------------------------------

When I press "enter" I get this message:

Traceback (most recent call last):
File "C:\Users\5ar5r\Desktop\keops.py", line 1,
in a = float(input("Vnesi ja osnovata (a) = "))
ValueError: could not convert string to float: ''

I try to get a number value from the input and when I press "enter" I expect that Python will convert empty string into number 0, but it does not. Please, can you explain to me where the problem is?
Reply


Messages In This Thread
string to float conversion fails - by PetarPetrenko - Feb-21-2024, 04:56 PM
RE: string to float conversion fails - by DPaul - Feb-21-2024, 06:21 PM
RE: string to float conversion fails - by DPaul - Feb-22-2024, 09:41 AM
RE: string to float conversion fails - by DPaul - Feb-22-2024, 04:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error could not convert string to float: deadendstreet 4 5,446 Oct-02-2019, 05:49 PM
Last Post: ichabod801
  ValueError: could not convert string to float: 'Pencil' Balakay97 3 5,954 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