0

Would like to clarify why it is error message

print(int(“4.0”) + int(“3”)) so it returns error cause of 4.0 is float not integer?

19th Nov 2019, 10:57 PM
THEGreatGatsby
THEGreatGatsby - avatar
3 Respuestas
+ 1
Not to be rude, but don't you think it's obvious ? You can't convert any text to an integer, it has to contain numbers ONLY, and 4.0 is not just a string of numbers. If you want to convert 4.0 to an int, convert it to a float first, then to an int, like this; int(float('4.0'))
19th Nov 2019, 11:07 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
just to confirm it is from test and I got it right but would like second opinion
19th Nov 2019, 11:09 PM
THEGreatGatsby
THEGreatGatsby - avatar
+ 1
THEGreatGatsby feel free to ask as many questions as you like, but it's not a good sign when you keep asking such questions that you could easily find an answer to using a search engine like google or duckduckgo. This shows that you're not even trying to make an effort to undertand what and where the problem is. I hope you understand, thanks!
19th Nov 2019, 11:14 PM
Aymane Boukrouh
Aymane Boukrouh - avatar