(Solved!) float error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

(Solved!) float error

int1=5 x=float(int1) print(x) TypeError: 'float' object is not callable As i know it must be print as โ€œ5.0โ€ but itโ€™s not. What can i do? There is no problem with โ€œint()โ€ or โ€œstr()โ€ codes.

27th Dec 2023, 7:59 AM
Numan Batur
Numan Batur - avatar
11 Answers
+ 4
There is nothing wrong with your code. It prints 5.0
27th Dec 2023, 8:31 AM
Jan
Jan - avatar
+ 3
Please read the previous replies before posting "the code is correct." It is not necessary to keep repeating the same thing. It just bloats the thread.
28th Dec 2023, 10:48 AM
Lisa
Lisa - avatar
27th Dec 2023, 8:35 AM
Lisa
Lisa - avatar
+ 2
Thank you all. When i create a new project and write codes, working. I guess something causing error in my old project. Solved! I recognise there is a variable named โ€œfloatโ€ and it cause error. :) <3
27th Dec 2023, 8:42 AM
Numan Batur
Numan Batur - avatar
+ 2
There are some good lessons in this. - never use built-in names or keywords to name your variables - linking your code is always helpful to avoid misunderstanding - sometimes the bug is in the part of the code which you do not consider - read the error message carefully, because it does mention the specific line of code which caused the error
27th Dec 2023, 9:12 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Numan Batur , Please add (solved) to the title of your post.
27th Dec 2023, 10:05 AM
Rain
Rain - avatar
+ 1
Nothing wrong
27th Dec 2023, 12:19 PM
Clive Jesus John
Clive Jesus John - avatar
+ 1
Numan Batur , Code is correct and the answer is 5.0
27th Dec 2023, 8:38 PM
Shantanu Kanojia
Shantanu Kanojia - avatar
0
Thanks for your commet but itโ€™s still same. Traceback (most recent call last): File "./Playground/file0.py", line 47, in <module> x=float(int1) TypeError: 'float' object is not callable
27th Dec 2023, 8:34 AM
Numan Batur
Numan Batur - avatar
0
Code is correct ๐Ÿ’ฏ
28th Dec 2023, 10:39 AM
Josephine Njemanze
Josephine Njemanze - avatar
0
If u wanna solve and teach something you can check my other questions guys ๐Ÿ˜… Thank you all
28th Dec 2023, 10:50 AM
Numan Batur
Numan Batur - avatar