Write a statement that calls the recursive function backward

Write a statement that calls the recursive function backwards_alphabet() with parameter starting_letter.?

Write a statement that calls the recursive function backwards_alphabet() with parameter starting_letter.

Solution

def backwards_alphabet(curr_letter):
if curr_letter == \'a\':
print(curr_letter)
else:
print(curr_letter)
prev_letter = chr(ord(curr_letter) - 1)
backwards_alphabet(prev_letter)
starting_letter = \'f\'
backwards_alphabet(starting_letter);

Output:

sh-4.3$ python main.py                                                                                                                                                                                                      

f                                                                                                                                                                                                                           

e                                                                                                                                                                                                                           

d                                                                                                                                                                                                                           

c                                                                                                                                                                                                                           

b                                                                                                                                                                                                                           

a

Write a statement that calls the recursive function backwards_alphabet() with parameter starting_letter.? Write a statement that calls the recursive function ba

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site