Here is the code:
aList = []
for p in anotherList:
aList.append(p)
try:
k=p.someMethod()
aList.append(k) #getting error here
except someException:
continue
return aList
I am getting “Global name error–aList not defined.Why so?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If
aListis not defined you should have received the error onaList.append(p)at the top of your loop before you get toaList.append(k)in try-except clause. Are you sure you don’t have a typo?