stack in pyton and some problems solutions