What keyboard command we have to stop an infinite loop in Python?

PythonServer Side ProgrammingProgramming

Any loop is formed to execute a certain number of times or until a certain condition is satisfied. However, if the condition doesn't arise, loop keeps repeating infinitely. Such an infinite loop needs to be forcibly stopped by generating keyboard interrupt. Pressing ctrl-C stops execution of infinite loop

>>> while True:
print ('hello')


hello
hello
hello
hello
hello
hello
Traceback (most recent call last):
File "<pyshell#18>", line 2, in <module>
print ('hello')
KeyboardInterrupt
raja
Published on 15-Feb-2018 19:26:37
Advertisements