1

Code needed

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

13th Jan 2018, 3:41 AM
mYstic
mYstic - avatar
18 Answers
13th Jan 2018, 7:10 AM
Ace
Ace - avatar
+ 7
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
13th Jan 2018, 3:07 PM
Ace
Ace - avatar
+ 6
May I ask what have you tried?
13th Jan 2018, 3:44 AM
Ace
Ace - avatar
+ 6
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
13th Jan 2018, 4:20 AM
Ace
Ace - avatar
+ 3
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
13th Jan 2018, 4:03 AM
Ace
Ace - avatar
0
Well im not very good at python and im sure there is a way to add it without having multiple variables
13th Jan 2018, 3:46 AM
mYstic
mYstic - avatar
0
This is my calculator
13th Jan 2018, 3:46 AM
mYstic
mYstic - avatar
0
Its the best i have but i dont like a much shorter way
13th Jan 2018, 3:47 AM
mYstic
mYstic - avatar
0
'But i would like a much shorter way'
13th Jan 2018, 3:47 AM
mYstic
mYstic - avatar
0
Thanks ill try it
13th Jan 2018, 4:04 AM
mYstic
mYstic - avatar
0
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
13th Jan 2018, 4:15 AM
mYstic
mYstic - avatar
0
Can you explain to me how to do that please?
13th Jan 2018, 4:26 AM
mYstic
mYstic - avatar
0
I think thats what i need
13th Jan 2018, 4:26 AM
mYstic
mYstic - avatar
0
Thats good but ud like to input it so you skip a line after each number and it adds for you
13th Jan 2018, 2:42 PM
mYstic
mYstic - avatar
0
Id
13th Jan 2018, 2:43 PM
mYstic
mYstic - avatar
0
Im trying to make it so it adds the numbers for you automatically in the code but on mine doesn't work
13th Jan 2018, 8:04 PM
mYstic
mYstic - avatar