Skip to content

Commit 983dd8a

Browse files
committed
Remove final mention of strcalc.R
1 parent 19de210 commit 983dd8a

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

2-working.md

+14-16
Original file line numberDiff line numberDiff line change
@@ -270,27 +270,25 @@ $ git commit --all --message "Return None, not 0, on invalid input"
270270

271271
Finally, let's add support for subtraction:
272272

273-
~~~R
274-
compute = function(input_string) {
275-
values = unlist(strsplit(input_string, ' '))
276-
num0 = as.integer(values[1])
277-
operator = values[2]
278-
num1 = as.integer(values[3])
279-
if (operator == '+') {
280-
return(num0 + num1)
281-
} else if (operator == '-') {
282-
return(num0 - num1)
283-
} else {
284-
print('unknown operator!')
285-
return(NA)
286-
}
287-
}
273+
~~~python
274+
def compute(expression):
275+
values = expression.split(' ')
276+
num0 = int(values[0])
277+
operator = values[1]
278+
num1 = int(values[2])
279+
if operator == '+':
280+
return num0 + num1
281+
elif operator == '-':
282+
return num0 - num1
283+
else:
284+
print('unknown operator!')
285+
return None
288286
~~~
289287

290288
Let's commit the changes:
291289

292290
```console
293-
$ git add strcalc.R
291+
$ git add calc.py
294292
$ git commit -m "Add support for subtraction"
295293
```
296294

0 commit comments

Comments
 (0)