everyone! I am a beginner in python programming. I am writing a python program to reverse a given input list. Following is the code for it:
L1=list(input("Enter the numbers of list to be reversed : "))
L2=[]
def rever(La,Lb):
if len(Lb)==0:
return La
else:
return rever(La.append(Lb.pop(0)),Lb)
print rever(L2,L1)
For example, if we input,
1,2,3
The output should be,
[3,2,1]
But this is not happening. Python is giving the following error:
Traceback (most recent call last):
File "Q3.py", line 10, in <module>
print rever(L2,L1)
File "Q3.py", line 8, in rever
return rever(La.append(Lb.pop(0)),Lb)
File "Q3.py", line 8, in rever
return rever(La.append(Lb.pop(0)),Lb)
AttributeError: 'NoneType' object has no attribute 'append'
I don't get it. Please help me out!!