Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

str object is not callable python

I have tried looking around for an answer however the questions on here either seemed to advanced (I'm new to Python) or because of redefining what something meant which I couldn't catch in my script. Here is the code-

a = float(input("Enter the length(in inches)"))
b = float(input("Enter the width(in inches)"))
print ()
print ("The area of your shape is: "(a*b))

I am getting the error TypeError: 'str' object is not callable.

It is a simple script, I know, but it's a work in progress.

like image 302
user1630407 Avatar asked Jun 01 '26 11:06

user1630407


2 Answers

Assuming you're using Python 3,

print ("The area of your shape is: ", (a*b))
#                                   ^

You forgot a comma.

like image 107
kennytm Avatar answered Jun 04 '26 01:06

kennytm


You can print the value either with:

print ("The area of your shape is: ", (a*b))

or with

print ("The area of your shape is: {}".format(a*b))
like image 21
pcalcao Avatar answered Jun 04 '26 00:06

pcalcao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!