selfteaching / selfteaching/selfteaching-python-camp

Day04 while语句很容易死循环,或者直接不执行的原因(尤其是嵌套while语句)的解决方法

Open
#295 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

学习心得分享
Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description

1、死循环的原因是“没有给(变量a)设置一个限制”,或者“没有让a跳出限制”,如a=a+1。。
2、while不执行的原因可能是条件限制太大
3、while1+while2语句这种嵌套式的语句,在while2执行完循环以后,在while2末尾如果没有给变量b赋一个初始值/置零等操作,如 在执行完b=b+1很多次后,没有执行b=0,也就是没有把变量b打回原形,就会导致只执行一次while2,且while1/2无法再次执行。造成程序死机卡住。
关键步骤:执行一次while后需要给变量赋值

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue body is the only supplied starting point and names no file, test, or entry point. Review the described while and nested-while cases, then identify the project location where this explanation belongs and define completion as a clear, accurate explanation with reproducible examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.