Here is the simple solution with Python and while loop:
while
import math def sayMeOperations(string_numbers): list_string_numbers = string_numbers.split(' ') index = 0 result_str = '' while index < len(list_string_numbers): if index == len(list_string_numbers)-2: break number_one = int(list_string_numbers[index]) number_two = int(list_string_numbers[index+1]) result = int(list_string_numbers[index+2]) if (number_one + number_two) == result: result_str += 'addition, ' elif int(number_one - number_two) == result: result_str += 'subtraction, ' elif int(number_one * number_two) == result: result_str += 'multiplication, ' elif math.floor(number_one / number_two) == result: result_str += 'division, ' index += 1 return result_str[0:-2]
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here is the simple solution with Python and
while
loop: