Home  >  Article  >  Backend Development  >  How to implement infinite loop statement in python

How to implement infinite loop statement in python

coldplay.xixi
coldplay.xixiOriginal
2021-03-02 16:49:3623584browse

How to implement infinite loop statement in python: In the while loop statement, you can achieve infinite loop by making the judgment condition never reach False. The code is [while var == 1:print("var = 1 ")].

How to implement infinite loop statement in python

The operating environment of this tutorial: Windows 7 system, python version 3.9, DELL G3 computer.

How to implement infinite loop statements in python:

Python infinite loop: In the while loop statement, you can achieve an infinite loop by making the judgment condition never reach False. .

Conditional expression:

# var = 1
# while var == 1:  # 表达式永远为 True
#     print("var = 1")
# # var = 1
#    ...
# # var = 1

Boolean value:

# while True:
#     print("条件为真")
# # 条件为真
#    ... 
# # 条件为真

Related free learning recommendations: python video tutorial

The above is the detailed content of How to implement infinite loop statement in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn