current position：Home>In Python, the condition setting and interpretation of while loop
In Python, the condition setting and interpretation of while loop
2022-02-03 00:28:23 【CSDN Q & A】
The phenomenon and background of the problem
while True: In condition settings ,True Of T Can you use lowercase letters ？ This True Conditions , When to jump out of the loop
Problem related code , Do not paste screenshots
>>> import random>>> import easygui as eg>>> eg.msgbox(" Welcome to the world of guessing numbers ！！！")'OK'>>> eg.msgbox(" Welcome to the world of guessing numbers ！！！",ok_button = " continue ")' continue '>>> da = random.randint(1,100)>>> m = eg.integerbox(msg = " Please input your guess number ",title = " Take a guess ",lowerbound = 1,upperbound = 100)>>> while True: if da == m: eg.msgbox(" That's right , Are you the roundworm in my stomach ？") eg.msgbox(" hum ！ There is no reward for guessing right ！") else: if da > m: eg.msgbox(" The small , The small ") else: eg.msgbox(" big , big ") m = eg.integerbox(msg = " Please enter the number you guessed again ",title = " Take a guess ",lowerbound = 1,upperbound = 100)>>>eg.msgbox(" Game over , Don't play ！！")
Operation results and error reporting contents
My solution ideas and tried methods
What I want to achieve
Refer to the answer 1：
Add one break Dropped out
import randomimport easygui as egeg.msgbox(" Welcome to the world of guessing numbers ！！！")'OK'eg.msgbox(" Welcome to the world of guessing numbers ！！！", ok_button=" continue ")' continue 'da = random.randint(1, 100)m = eg.integerbox(msg=" Please input your guess number ", title=" Take a guess ", lowerbound=1, upperbound=100)while True: if da == m: eg.msgbox(" That's right , Are you the roundworm in my stomach ？") eg.msgbox(" hum ！ There is no reward for guessing right ！") break else: if da > m: eg.msgbox(" The small , The small ") else: eg.msgbox(" big , big ") m = eg.integerbox(msg=" Please enter the number you guessed again ", title=" Take a guess ", lowerbound=1, upperbound=100)eg.msgbox(" Game over , Don't play ！！")
Refer to the answer 2：
Refer to the answer 3：
python in True and False Is the key word , Valid in uppercase , Lowercase is not a variable name .
Refer to the answer 4：
author[CSDN Q & A],Please bring the original link to reprint, thank you.
The sidebar is recommended
- How to use stu method to input student names and grades in pyton and store them in the list
- If you enter the title of a book, the length of each title is no more than 100, and the books are sorted in ASCII order from small to large. Enter the number of book titles indefinitely until the end of the document. Sort the string from small to large ac
- Python selenium loading is slower than opening the web card normally. Is there any solution
- When the database connection is normal, it is impossible to add, delete, modify and query the data in the database
- How to realize NS3 traffic load distribution
- How to enter the grades of each subject? Do you need a two-dimensional array for each subject
- Please answer what this is
- How to define and initialize structures in. H
- In C language, the input content is larger than the defined array, but can it be output?
- The running result is not expected (c + +)
guess what you like
matlab . Image pixel processing
The process of solving these more than 2000 functions through subs is too slow
Longest common prefix, binary search problem
Basic HTML5 code table and usage
Error is reported after Vue project is started. Please ask for help
How can I open the database in the examinee's folder for computer level 2 MySQL test questions?
The following program (function) deletes the characters exactly the same as the string S2 in the string S1, such as S1: China S2: in, and the result is cha
Why NP The empty ((3,2)) element is not random?
Why do you report an error? Find a solution
Using C + + and pcap H and iphlpapi H. how to solve the problem?
- How can I fix the problem of uploading to idea
- com. fasterxml. jackson. databind. Objectmapper throw exception
- What is the reason and how to solve it
- Preparestatement of javajdbc
- int x=8,y=12,z=14 ; x++,y=z++,z=++x; y=x%z- -; Find the value of XYZ
- Why is this the case when I access the PHP test program under localhost in MacOS?
- Why should this code be int & n instead of int n? In C + +, under what circumstances do you need to be int & n
- The redis session problem runs well locally. As soon as it arrives online, it crazy reports exceptions. It starts to report when it starts. And the function can be used normally
- Research on Professional Course Scheduling Based on nonlinear programming
- The question about C + +: that's it: include 'Einstein h'
- Sqlyog failed to import the database. I don't know what to do
- The Microsoft edge browser can only enter the address in the address bar and cannot search
- Why can't data be saved when text is written in this way?
- When the user logs in and out, a socket error is reported when he logs in again
- The website editor cannot be right-click pasted and cannot be used
- On the problem of multi-threaded ball taking and putting (language Java)
- Start the flume script and report an error in the generated log file: agent configuration for 'A1' has no configfilters
- What can reflect the professional quality of a yard farmer?
- Why is the returned hour, minute and second Nan
- Python, C problem - leap year judgment
- SQL. Why not attach it, as shown in the figure
- How does robotjs set automatic rebuild in electronic build
- Python final exam SOS
- I admit that I have degenerated, but I still want to know how to solve Java
- I have encountered several array problems in C + +. I hope the big God can solve the puzzle. It's best to have comments
- Why is it double? don't get it
- C language novice village, high adoption rate
- The usage and law of this function are expected to be explained.
- Let's see what's wrong. My code will output one less country
- Why is the average 0
- The replacement of tab key in hive leads to a problem in the file.
- Now to realize a function, use the El tree component of element UI, select the relevant node, and then copy a new tree with only relevant parent-child nodes below.
- Sqlyog database import failed with the following error. Do you know
- How do two lists compare in the same location
- How to group the following data by film and television, education, music, E-sports and other sectors
- Server socket + Android socket can only send a message once after connecting. The second sending does not respond. You need to reconnect the socket and solve it
- Questions about student information management system C++
- Qtable widget of QT double click to edit and display the problem
- Separate strings and insert a comma for each 5 characters
- QT qtablewidget double click to modify the content. What is the problem