Home > other >  Python problem, bosses face
Python problem, bosses face

Time:11-23

Why the first output is not a mushroom? I was a little white, can't understand why? Bosses enjoy a face to solve, thank

CodePudding user response:

Words are spelt wrong, is not request_topping requested_topping

CodePudding user response:

The building Lord, you of the above code should be an error, how there will be those printed, request_topping there is no definition of ah, to requested_topping can

CodePudding user response:

reference 1/f, ice all over the sky the wind response:
words are spelt wrong, is not request_topping requested_topping

Thank you bosses to give directions

CodePudding user response:

refer to the second floor AutumnSea03 response:
the building Lord, you have the above code should be an error, how there will be those printed, request_topping there is no definition of ah, to requested_topping can

Thank you bosses to give directions

CodePudding user response:

The building Lord, you will have an error code to run
See the following content:

1, your code of a requested_topping hand mistakenly written as request_topping
2. Normally, no variables defined, will quote NameError: the name 'request_topping' is not defined
wrong3, your code is not an error, it may be that you have defined in the previous, called request_topping variables, so there is no error
4, the revised code to run logic is as follows:
(1) the first line: define a list requested_toppings
(2) the second line: use the for loop traverse the list, for each element
(3) the third line: whether the element is equal to green peppers
(4) the fourth row: if the judgment condition was established, the printed We have sold out green peppers
Line (5) the fifth: if not, then execute the the else statement after ,
(6) line 6: the printed adding + requested_topping value + the dot - '. '
Line 7 (7) : complete list traversal, print the content of the last sentence, the a newline + Finish your pizza

5, therefore, the output of the revised contents are as follows:
addingmushrooms.
We have sold out green peppers
Addingextra chese.

Finish your pizza

CodePudding user response:

refer to fifth floor said coke python response:
the building Lord, you will have an error code to run
See the following content:

1, your code of a requested_topping hand mistakenly written as request_topping
2. Normally, no variables defined, will quote NameError: the name 'request_topping' is not defined
wrong3, your code is not an error, it may be that you have defined in the previous, called request_topping variables, so there is no error
4, the revised code to run logic is as follows:
(1) the first line: define a list requested_toppings
(2) the second line: use the for loop traverse the list, for each element
(3) the third line: whether the element is equal to green peppers
(4) the fourth row: if the judgment condition was established, the printed We have sold out green peppers
Line (5) the fifth: if not, then execute the the else statement after ,
(6) line 6: the printed adding + requested_topping value + the dot - '. '
Line 7 (7) : complete list traversal, print the content of the last sentence, the a newline + Finish your pizza

5, therefore, the output of the revised contents are as follows:
addingmushrooms.
We have sold out green peppers
Addingextra chese.

Finish your pizza

Thank you very much, give so many words so I was embarrassed by heart

CodePudding user response:

Hope useful to you
  • Related