In Python, conditional statements consist of if
, if-else
, and if-elif-else
:
|
|
|
|
|
Recursion is just as elegant in Python! Below is the well known Fibonacci function.
|
Using conditionals and recursion write the palindrome(string)
predicate function in Python, which should return True
if the input string is a palindrome and False
otherwise. Find Exercise 4 in the virus.py starter file and fill out the function definition. When you want to test your solution, enter the following command:
python3 virus.py palindrome
To confirm that you've completed all of the exercises enter the folowing command and show the output to your teacher:
python3 virus.py run_tests