int(), float() and str() in python? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

int(), float() and str() in python?

Why does this statement produce an error: print (int('70.0'))

28th May 2021, 4:36 PM
Alaa Aldeen Shammr
Alaa Aldeen Shammr - avatar
3 Respuestas
+ 3
ᎪᏞᎪ'Ꭺ ᎪᏞᎠᎬᎬΝ ՏᎻᎪᎷᎷᎡ Actually int() function expects an integer string or a float, but not a float string. If a float string is given, you need to convert it to float first then to int as: int(float(userGuess)) Inherited from: https://stackoverflow.com/questions/27048627/how-to-convert-a-float-string-to-an-integer-in-JUMP_LINK__&&__python__&&__JUMP_LINK-3
28th May 2021, 4:57 PM
Genuine Stalwart
Genuine Stalwart - avatar
+ 1
Because you missed the last closing parentheses of print()
28th May 2021, 4:38 PM
Genuine Stalwart
Genuine Stalwart - avatar
+ 1
Genuine Stalwart Ok Try it now
28th May 2021, 4:47 PM
Alaa Aldeen Shammr
Alaa Aldeen Shammr - avatar