while True:
s = raw_input('Enter something : ') if s == 'quit':
$ python break.py
Enter something : Programming is fun
Length of the string is 18
Enter something : When the work is done
Length of the string is 21
Enter something : if you wanna make your work also fun: Length of the string is 37
Enter something : use Python!
Length of the string is 12
Enter something : quit
Done
In this program, we repeatedly take the user's input and print the length of each input each time. We are providing a special condition to stop the program by checking if the user input is'quit'. We stop the program by breaking out of the loop and reach the end of the program.
The length of the input string can be found out using the built-inlen function.Remember that thebreak statement can be used with thefor loop as well.
Programming is fun
When the work is done
if you wanna make your work also fun: