0

i'm writing my first program in python. I have a function that should save a number in a txt file. This number is obtained with some math, converted in int, (just because i need only the integer part) then in string. Then saved into txt.

Here i just deleted the saving part and replaced with print.

str=140

str0 = float(str0)
str = float(str)
perc0 = 100-(str*100/str0)
perc0 = int(perc0)
perc0 = str(perc0)
print(perc0)

But the result is

File ".\temp.py", line 10, in <module>
perc0 = str(perc0)
TypeError: 'float' object is not callable

What am i doing wrong? Sorry for dumb question, but after some research i don't really know what's wrong, meybe i'm missing some basics

2
  • don't use str as a variable as str is a protected keyword in python. See documentation Commented Feb 7, 2021 at 19:52
  • You are using a protected keyword (str) for your variable name. Change that and it should be fine. Commented Feb 7, 2021 at 19:53

1 Answer 1

2

str is a keyword in python. You should avoid using that as a variable name.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. as i said i was sure it was a dumb error...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.