loops - How to restart a program in python? -


im student, , started learning python month back, right now, have learnt basics. teacher had given me qeustion this, , problem is, dont know how rerun program, suppose, after finding area of particular shape, want loop printing first statement. there way of doing without rerunning program using "f5" key? thankyou.

 print "1. triangle"  print "2. circle"  print "3. rectangle"   shape= input("please select serial number =")   if shape==1:      a=input("base =")      b=input("height =")      area=0.5*a*b      print area  if shape==2:      a=input("radius =")      area=3.14*a*a      print area  if shape==3:      a=input("width")      b=input("length")      area=a*b      print area 

if want restart, use simple while loop.

while true:     # lovely code 

then put validation @ end:

    again = raw_input("play again? ")     if again.startswith('n') or again.startswith('n'):         break     else:          continue 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -