Exercise 17: Try Catch

Let's test your understanding of using try catch in R code.

Problem Statement

Implement a function calculateLog() that takes a testVariable and prints its log. If the logarithmic value of the testVariable is not possible, print “This operation is not allowed!”

Use the cat() function for printing!


A testVariable containing the data whose logarithmic value needs to be found.


The correct output based on the testVariable.

Sample Input


Sample Output

This operation is not allowed!

Test Yourself

Write your code in the given area. If you get stuck, you can look at the solution.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy