Im trying to make a code that can infinitely add numbers with an input like so to add them Ex: 1 1 1 Output: 3 So, after each number you add you skip a line I would prefer this code to be in python
A demo of what you want https://code.sololearn.com/c5pwFPaUFMTx/?ref=app
It works as a normal calculator would. You enter your expression and press enter. If you have multiple expressions, enter them on separate lines and press enter when done
May I ask what have you tried?
The documentation for eval may give you clues as to what it needs https://docs.python.org/3/library/functions.html#eval Also, you should use an exception handling block within the loop to detect eof to break from the loop
Well, recall how Python has the eval function which will do a lot of work for you if you are going for the shortest approach. To keep getting input, just put everything in an infinite loop. When will it terminate? Just search for an EOF in the input
Well im not very good at python and im sure there is a way to add it without having multiple variables
This is my calculator
Its the best i have but i dont like a much shorter way
'But i would like a much shorter way'
Thanks ill try it
https://code.sololearn.com/cRfmKDBp8Gdy/?ref=app This is what ive got so far but i dont get why the it wont cause it works on my calculator
Can you explain to me how to do that please?
I think thats what i need
Thats good but ud like to input it so you skip a line after each number and it adds for you
Im trying to make it so it adds the numbers for you automatically in the code but on mine doesn't work
Unable to overload +
I have tried every way I could find but still I can't display my local images ..what am I doing wrong?
Pls rectify the errors.
Python list half printed