What's the reason for something being 'not callable'? Thanks | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's the reason for something being 'not callable'? Thanks

Not callable' error

12th Sep 2021, 12:14 PM
Emma Cooke
8 Answers
+ 4
Emma Cooke 1 - There should be x < 4 since there are only 4 inputs 2 - there should be sum = sum + 10 and sum = sum - 20, print is a function but you used as a variable, there should be sum instead of print 3 - remove sum += x
12th Sep 2021, 12:51 PM
A͢J
A͢J - avatar
+ 1
Hi Emma! That's because you assigned variable print = 10 & print = -20 Then you wrote print(sum). That is interpreted as meaning a function call on the object bound to print, which is an int. And that fails. The problem is code binds an int to the print since you used it as a variable name. You can change it as sum instead. Also, your code needs input() function to take inputs. But you're missing it too.
12th Sep 2021, 12:57 PM
Python Learner
Python Learner - avatar
+ 1
Seems like your problem isn't solved yet. You can understand your mistakes from here. This should work sum = 100 x = 0 while x < 4: a = input() if a == ("hit"): sum += 10 elif a == ("miss"): sum -= 20 x += 1 print(sum)
12th Sep 2021, 4:29 PM
Python Learner
Python Learner - avatar
+ 1
Thank you! Yes that worked.
12th Sep 2021, 5:35 PM
Emma Cooke
0
Yes
12th Sep 2021, 12:27 PM
Emma Cooke
0
This is my code. sum = 100 x = 0 while x <= 4: sum += x if x == ("hit"): print = 10 elif x == ("miss"): print = -20 x += 1 print(sum) Where do you want me to put the print(x())? I've tried double brackets with the sum. Is that what you meant?
12th Sep 2021, 12:34 PM
Emma Cooke
0
The error is on line 11 (last line). I don't know how to make my code public or DM someone. Thanks for all the advice so far.
12th Sep 2021, 1:20 PM
Emma Cooke
- 2
13th Sep 2021, 10:46 AM
Coding
Coding - avatar