break statement jumps out of the closest enclosing loop
The break statement causes an immediate exit from a loop.
The following code creates an interactive loop.
It uses the input method which is raw_input in Python 2.X.
The code exits when the user enters "stop" for the name request:
while True: name = input('Enter name:') # Use raw_input() in 2.X if name == 'stop': break age = input('Enter age: ') print('Hello', name, '=>', int(age) ** 2)
This code converts the age input to an integer with int before raising it to the second power.
The input returns user input as a string.