How to do it??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to do it???

The input is the expression x+y, where x and y are digits, i.e. integers from 0 to 9 inclusive. You need to calculate it and output the result. The first line contains a single integer t (1≤t≤100) — the number of input data sets. For example: Input: "5+3 6+8 7+3" Conclusion: "8 14 10"

21st Feb 2023, 1:47 PM
python
3 Answers
+ 4
What is your question? edit: Split the input at the blank space to separate the expressions. Then you can split the individual expression at "+" to get get x and y. Once you have x and y, convert them to a numeric data type and add them
21st Feb 2023, 1:57 PM
Lisa
Lisa - avatar
+ 3
That would be the lazy version that the teacher probably did not intend ;)
21st Feb 2023, 3:39 PM
Lisa
Lisa - avatar
+ 2
Lisa maybe directly passing the splitted value in eval will be a better choice
21st Feb 2023, 3:20 PM
I am offline
I am offline - avatar