Question DSA-REC-0013
MediumWhat is the output of this code?
def rev(s):
return s if len(s) <= 1 else rev(s[1:]) + s[0]
print(rev("abcd"))
- A.
d
- B.
abcd
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Recursion and Backtracking question
What is the output of this code?
def rev(s):
return s if len(s) <= 1 else rev(s[1:]) + s[0]
print(rev("abcd"))
d
abcd
Sign up free to see the answer and a step-by-step explanation.
a
dcba