Substitute inside a string | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

Substitute inside a string

If the user inputs "5,7" instead of "5.7", the float conversion would not work. How do you substitute the comma with the point in the input value?

1st Jul 2019, 9:32 AM
Jacopo
Jacopo - avatar
1 Réponse
+ 8
It's very simple: print(float(input().replace(",", ".")))
1st Jul 2019, 9:36 AM
Airree
Airree - avatar