Neural Sync Active
Jan 2026 - Python - Week 9 - WEEK9-GrPA 1
Registry Synced
Jan 2026 - Python - Week 9 - WEEK9-GrPA 1
570 words
3 min read
WEEK9-GrPA 1
Course: Jan 2026 - Python
WEEK9-GrPA 1
Submission deadline has passed for this assignment
Due Apr 17, 2026 at 11:59 PM IST
Instructions
Use "Test Run" to verify your code with public test cases.
Press "Submit" to have your assignment evaluated.
You can submit your assignment multiple times up until the deadline.
Make sure to submit your final code by the deadline to receive your score.
Summary
100 out of100
Score
Public Tests
3/3 Passed
Submitted on Apr 17, 2026 at 5:35 AM IST
Private Tests
5/5 Passed
Submitted on Apr 17, 2026 at 5:35 AM IST
Write a recursive function named reverse that accepts a list L as argument and returns the reversed list.
You do not have to accept input from the user or print output to the console. You just have to write the function definition.
Public Tests ( 3/3 )
Case 1
Input:
textpublic [1, 2, 3, 4]
Expected Output:
text[4, 3, 2, 1]
Actual Output:
text[4, 3, 2, 1]
Case 2
Input:
textpublic [10, 5, 1, 4, 9]
Expected Output:
text[9, 4, 1, 5, 10]
Actual Output:
text[9, 4, 1, 5, 10]
Case 3
Input:
textpublic ['a', 'b', 'c', 'd', 'e', 'f']
Expected Output:
text['f', 'e', 'd', 'c', 'b', 'a']
Actual Output:
text['f', 'e', 'd', 'c', 'b', 'a']
Private Tests ( 5/5 )
Case 1
Input:
textprivate [(1, 2), (3, 4), (5, 6), (7, 8)]
Expected Output:
text[(7, 8), (5, 6), (3, 4), (1, 2)] Good, your function is recursive
Actual Output:
text[(7, 8), (5, 6), (3, 4), (1, 2)] Good, your function is recursive
Case 2
Input:
textprivate [1.0, 2.9, 5.9, -10.4, 13, 19, 90]
Expected Output:
text[90, 19, 13, -10.4, 5.9, 2.9, 1.0] Good, your function is recursive
Actual Output:
text[90, 19, 13, -10.4, 5.9, 2.9, 1.0] Good, your function is recursive
Case 3
Input:
textprivate ['singleton']
Expected Output:
text['singleton'] Good, your function is recursive
Actual Output:
text['singleton'] Good, your function is recursive
Case 4
Input:
textprivate ['two', 'items']
Expected Output:
text['items', 'two'] Good, your function is recursive
Actual Output:
text['items', 'two'] Good, your function is recursive
Case 5
Input:
textprivate [(1, 2, 3), (4, 5, 6), (7, 8, 9), (10, 11), (12, 13), (14, 15, 16), (17, 18), (19, 20)]
Expected Output:
text[(19, 20), (17, 18), (14, 15, 16), (12, 13), (10, 11), (7, 8, 9), (4, 5, 6), (1, 2, 3)] Good, your function is recursive
Actual Output:
text[(19, 20), (17, 18), (14, 15, 16), (12, 13), (10, 11), (7, 8, 9), (4, 5, 6), (1, 2, 3)] Good, your function is recursive
💻 IITM Official Solution
pythondef reverse(L): if len(L) <= 1: return L # Bring the last element to the front # And reverse the first n - 1 elements return [L[-1]] + reverse(L[:-1])
💻 My Submitted Code
pythondef reverse(L): """ A recursive function to reverse a list L Arguments: L: list Return: result: list """ # Base case if len(L) <= 1: return L # Recursive case return reverse(L[1:]) + [L[0]]