Nesting Code Three Levels Deep
while True: reply = input('Enter text:') if reply == 'stop': break # w w w. j a va 2s. c o m elif not reply.isdigit(): print('Bad!' * 8) else: num = int(reply) if num < 20: print('low') else: print(num ** 2) print('Bye')
Here, we add an if statement nested in the else clause of another if statement.