Home > other >  For help: the problem of the while loop
For help: the problem of the while loop

Time:09-29

Written the following code, don't understand why the input for the first time are not performed while the print command; But in the second input to print,
Can someone help to point out where there is a problem?

CodePudding user response:

Process
The first is the while input (* * * *)!="* * *"
To perform the input, waiting for input,
Enter aa
Judgment is not equal to quit
Began to perform a print (input (* * *))
First the input waiting for input
Enter AA
Print the AA
The next cycle

CodePudding user response:

You use, the first is the content of the input while statement in the input (prompt), then the while loop in comparison, displays the contents of a second prompt again, now you just to input the content of the print () function to print; Simple, you of the program, two other inputs to calculate a while loop,

CodePudding user response:

 
Def replay () :
Prompt='Tell me something, and I will repeat it back to you.'
The content=input (prompt + "\ n the enter" quit "to end the talk:")
While the content! :='quit'
Print (content)
Return replay ()

Replay is ()

So that you can realize your content

CodePudding user response:

refer to the second floor Hajo_ response:
you use, the content of the first input is the input in the while statement (prompt), and then the while loop in comparison, displays the contents of a second prompt again, now you just to input the content of the print () function to print; Simple, you of the program, two other inputs to calculate a while loop,


Two other input is a cycle, is the cause of this while I module, two input is relatively independent?
To the input (xx) assignment won't appear this kind of situation right, this is a specification?

CodePudding user response:

reference 4 floor Lu Han reply:
Quote: refer to the second floor Hajo_ response:

You use, the first is the content of the input while statement in the input (prompt), then the while loop in comparison, displays the contents of a second prompt again, now you just to input the content of the print () function to print; Simple, you of the program, two other inputs to calculate a while loop,


Two other input is a cycle, is the cause of this while I module, two input is relatively independent?
To the input (xx) assignment won't appear this kind of situation right, this is a specification?

Two input is relatively independent,
Generally is endowed the input variable, but still depends on the specific circumstances and requirements, for this is the best you assigned to variables, at the same time use custom function to do better

CodePudding user response:

reference 4 floor Lu Han reply:
Quote: refer to the second floor Hajo_ response:

You use, the first is the content of the input while statement in the input (prompt), then the while loop in comparison, displays the contents of a second prompt again, now you just to input the content of the print () function to print; Simple, you of the program, two other inputs to calculate a while loop,


Two other input is a cycle, is the cause of this while I module, two input is relatively independent?
To the input (xx) assignment won't appear this kind of situation right, this is a specification?

Two input is relatively independent,
Generally is endowed the input variable, but still depends on the specific circumstances and requirements, for this is the best you assigned to variables, at the same time use custom function to do better

CodePudding user response:

refer to 6th floor Hajo_ response:
Quote: refer to 4th floor Lu Han reply:
Quote: refer to the second floor Hajo_ response:

You use, the first is the content of the input while statement in the input (prompt), then the while loop in comparison, displays the contents of a second prompt again, now you just to input the content of the print () function to print; Simple, you of the program, two other inputs to calculate a while loop,


Two other input is a cycle, is the cause of this while I module, two input is relatively independent?
To the input (xx) assignment won't appear this kind of situation right, this is a specification?

Two input is relatively independent,
Generally is endowed the input variable, but still depends on the specific circumstances and requirements, for this is the best you assigned to variables, at the same time use custom function to do better


Thank you very much! I understand!
  • Related