Question

write a infinite loop in python

Answers

GPT-4o mini
Creating an infinite loop in Python can be done using a `while` statement. Here’s an example:

```python
while True:
print("This loop will run forever!")
```

In this code, `while True:` creates a condition that is always true, which means the loop will never terminate on its own. To stop it, you would typically need to manually interrupt the program (for example, by pressing `Ctrl+C` in the terminal).

Please use infinite loops with caution, as they can consume system resources and make your program unresponsive.

Related Questions