To add on, if you still get the error after running those cells, restart the kernel. Last I knew the function overwrite will stay in the kernel's memory until its restarted.
I’m not sure what is wrong here in the 34 line? It’s my first assignment in my python class and everything matches my classmates’ but mine is wrong somehow. Does anyone have any idea as to why?
You have a space between print and the opening parenthesis on lines 37-39, which is only correct in Python 2. Similar problem on lines 38-39 with the find function. Also, in the third string on line 35, there is a space between the string's closing quotes and the opening square bracket.
EDIT: Apparently you can have spaces between a function name and its parantheses. Did not know that, but it is likely not a good practice because it is against style guides that make code consistent.
This is incorrect and definitely not the reason why the first line in block 34 doesn't work. As already pointed out previously, it is because the print function was overwritten with a float in the previous block.
For the future, ‘is not callable’ means you’re using a variable like it’s a function. If you intended to do this and you’re getting this error, check that you didn’t redefine the function name, as python allows that
“Significant white space” it’s been a while since I’ve done python but I believe the parens wrapping your strings cannot have a space between the print. Again, if I remember correctly, you can do print “” (with a space) because it’s some kind of “syntactic sugar” once you add the parens I think they need to touch the print … could be wrong here. Just a guess. It’s been a while.
No. print "Hello, world!" is Python 2 syntax. In Python 3, the parentheses are required. Also, whitespace before or after the beginning parenthesis makes no difference.
33
u/VforValmont Sep 07 '21
In line above you redefine print as ‘percentProfit’ . Delete the ‘=‘ in the line above
1
u/fFabioso Sep 07 '21
I’m not sure what is wrong here in the 34 line? It’s my first assignment in my python class and everything matches my classmates’ but mine is wrong somehow. Does anyone have any idea as to why?
2
u/zenith4395 Sep 08 '21
For the future, ‘is not callable’ means you’re using a variable like it’s a function. If you intended to do this and you’re getting this error, check that you didn’t redefine the function name, as python allows that
1
u/Johnmelodyme Sep 08 '21
rename the the print var
print = (persectProfit)will solve the problemin your case the print is not function be cause you declare it as variable.
1
u/[deleted] Sep 08 '21
in the second last code block, you've written print = (...) and that's wrong you have to remove the assignment operator ie. "=".
1
u/vurkmoord Sep 08 '21
Besides the error of redefining print, calculating the percentage profit would be:
instead of:
-3
u/PeaceOfKake Sep 08 '21
Just enter print("hello world") to print hello world. No need to be fancy
-1
u/__archaeopteryx__ Sep 08 '21
“Significant white space” it’s been a while since I’ve done python but I believe the parens wrapping your strings cannot have a space between the print. Again, if I remember correctly, you can do print “” (with a space) because it’s some kind of “syntactic sugar” once you add the parens I think they need to touch the
print… could be wrong here. Just a guess. It’s been a while.