+ 2
Splitting Input
Asssume that the input is given in a huge line of multiple input, for example: " 7 3 SUM 5 4 MUL 3 3 DIV ,etc". how can i command pyhton to read the last line as the operation, and splitting up those input so i can get the output of each operation one by one?
7 odpowiedzi
+ 3
fadhlan pasyah Look at the code, I updated it
+ 3
I updated the code again
+ 2
thankyou so much :)
+ 1
thankyou very much :)
0
Anna i would like to ask a follow-up question.
if the s changed into input like giving 2 number and operation in huge number, each n1 n2 op separated by an enter, i have tried to add the operation but the result is the python only calculate the first line i input.
How do i command python to count each line according to each of given operation keyword?
0
sorry, there was a mistake in my words so misunderstood happens :(.
https://code.sololearn.com/c6XTXRGAI16w/?ref=app
i tried to run this code and (ex.) 7 3 MUL works. but when i try to input:
7 3 MUL
4 8 SUM
9 3 DIV
6 6 SUB
etc;
the code just operate the top operation. how can i program it to read all lines from top to bottom and calculate one by one? it says that too many input to unpack if i tried the while True loop.
expected result:
21
12
3
0