Python Interviews: Difference between revisions

no edit summary
m (Protected "Python Interviews" ([Delete=Allow only logged in users] (indefinite) [Edit=Allow only logged in users] (indefinite) [Move=Allow only logged in users] (indefinite)))
No edit summary
Line 39:
“else” clause: It is useful if you want to run a piece of code when the try block doesn’t create an exception.
“finally” clause: It is useful when you want to execute some steps which run, irrespective of whether there occurs an exception or not.
 
* List Operations:
 
Insert integer at position 5 at position 0:
a.insert(0,5)
 
Delete the first occurrence of integer:
a.remove(6)
 
Insert integer at the end of the list:
a.append(9)
 
Sort the list:
a.sort()
 
Pop the last element from the list:
a.pop()
 
Reverse the list:
a.reverse()