Skip to content
← Back to Community
Help with Functions
Profile icon
ThatOneGuy1234

I made a simple calculator a while ago where you would have 2 numbers and all the basic operators and it would add them together. I wanted to be able to add more than 2 numbers, but I didn't want to be confined to a certain number of variables, so I tried using functions for the first time. You can see my code down there, and when you run it there are no syntax errors, but I don't know what's wrong with it. I defined calculator then ran it. Anyone know what's wrong?

Answered by Wumi4 [earned 5 cycles]
View Answer
Voters
Profile icon
lauro71
Profile icon
ThatOneGuy1234
Comments
hotnewtop
Profile icon
Wumi4

Hi!

You miss the necessary parenthesis (()) at the end of the Calculator function calling in Python!

To call the function, place a pair of parenthesis of every single time you call it.

Calculator()
Profile icon
ThatOneGuy1234

@Wumi4 Thanks! I also needed to add str in my parenthesis, but your answer was correct.

Profile icon
InvisibleOne

In python, there is a better way:

print(eval(input()))

I think your issue is on line 33, you didn't activate the function. Instead of just putting Calculator You should put Calculator() You need the parenthesis when calling a function

Profile icon
AbdulHannanU

It's working perfectly!