+ 1

Python3) Better solutions to allow multiple lines of user input?

I am coding a calculator, that would take calculations from multiple input line, if user don't use any input lines, it results to errors, my solution is try-except statement, but it needs too many lines of text, to able user type 16 lines of calculations, it needed more than 50 lines of code. I have also tried to use loops, but first I should know, how many lines of calculations user wrote, it could be done manually by user, if user tells, how many lines of calculations (s)he wants to make.

20th Apr 2018, 6:33 PM
Seb TheS
Seb TheS - avatar
3 Réponses
+ 5
Something you can do is take all input at once, as a string, then play around with it. You can compute it char by char and do actions depending on what’s happening. Take a look at this: https://code.sololearn.com/cUEVZ6d8Z57P/?ref=app Here’s a nice description of how to do that: https://www.sololearn.com/learn/704/
21st Apr 2018, 2:29 AM
Pedro Demingos
Pedro Demingos - avatar
+ 1
https://code.sololearn.com/cL1pQ0iQIWTC/?ref=app (The link of this code didn't fit to the description)
20th Apr 2018, 6:35 PM
Seb TheS
Seb TheS - avatar
0
no, I already did the 150 lines for Try:Except statements
21st Apr 2018, 9:57 AM
Seb TheS
Seb TheS - avatar