0

I'm very new to programming and am learning Python through Automate the Boring Stuff. I'm looking at While Loops and put the following into the file editor window:

name = ''
while name != 'your name':
     print('Please type your name.')
     name = input()
print('Thank you!')

In the interactive shell of IDLE, the author uses the following as an example of While Loops:

>>>
Please type your name.
your name
Thank you!
>>> while True:
          print('Hello!')

And then Hello! appears dozens of times. The book says to click Shell -> Restart Shell, or to use Ctrl + C to interrupt the execution. This does not work for me.

I'm using Python IDLE Shell 3.12.2, Lenovo IdeaPad Slim 5 16IRL8, and Windows 11.

I can't interrupt the execution as this bug is happening. I can only do this when the program is not going haywire. Otherwise, Ctrl + C, Ctrl + Fn + F6, and navigating the toolbar all work.

While the loop is happening, my keystrokes are ignored, and the toolbar is frozen when I try to click on anything. Eventually, I am told that Python is not responding, and I close the program. I don't want to lose my work in the future, so I would like to know how to fix this.

I have tried Ctrl + Fn + F6 to Restart Shell, which again only works when I'm not running the program above. I have tried a few other keys like D and \ instead of C as well, and these do not work. I do not see a Break or Pause key on my keyboard.

7
  • what is your question exactly? Commented Apr 9, 2024 at 5:32
  • while True: runs forever since the condition will never be false. its no bug whatsoever Commented Apr 9, 2024 at 5:32
  • 1
    This is a known bug, no resolution currently. Commented Apr 9, 2024 at 5:39
  • @Mr.Irrelevant Yes, I'm aware that the program is supposed to run forever. I do not have any questions about the code. This was part of a tutorial explaining what to do if your program is running forever and you want it to stop without closing the window. The book suggested Ctrl + C, which is not working for me. I meant to ask if there is another key sequence that could work, or some other solution, but it appears this is a problem with the IDLE software itself according to the other commenter here. Commented Apr 9, 2024 at 6:35
  • @AbdulAzizBarkat Thank you! After reading your comment, I tried this in Mu and was easily able to interrupt the execution like in the example. Thanks for helping me learn! Commented Apr 9, 2024 at 6:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.