[Python] Issue when doing float(input()) in python

Discussão em 'Python' iniciado por Stack, Julho 24, 2025.

  1. Stack

    Stack Membro Participativo

    I have a small issue that I "understand" but cannot fix. Imagine you have s = float(input("Write a number"))

    When on a linux terminal the user types 0.4 and press enter: Every thing is okay and s equal 0.4 When the user enters 0.5, sees it is wrong, deletes the 5 and types 4 instead and I have an error

    ValueError: could not convert string to float: '0.4\x083'

    It seems like it is an address instead of a string. If I ask the type(), it says it's a string. But if I str(), I get the string containing the address. But if I print it, I have the correct answer. Is there any easy fix for this ?

    Continue reading...

Compartilhe esta Página