0
I have problem understanding while loop
Can someone help me out with it?
9 Réponses
+ 4
The code should be
seat =5
while seat > 0:
print("sell pizza")
seat = seat -1 # subtraction not addition
https://sololearn.com/compiler-playground/cgzdrCcAMnBT/?ref=app
+ 3
Mercy ,
the link you posted does not work properly.
> to give you support, we need to see your code try, so please copy your code and insert it in your post.
> we also need to know the programming language you are using for the while loop issue.
+ 3
Mercy u simply click the share button (three connected dots in the right top corner) and press copy link.
As for the code, it didnt work because
1. Your starting variable was 0, hence the loop was skipped entirely, since the condition was not satisfied at start.
2. You can not perform assignment of a variable like that inside a print function.
+ 2
Aleksei Radchenkov thanks
Corrected it already
+ 1
The while loop simply executes whatever is inside of it, if the condition is true.
E.g. while(1!=0){i+=1} will increment i by 1 forever, since 1 is never equal to 0.
The concept should be fairly straightfoward. If you have some specific aspect of it that u don't understand, please clarify.
+ 1
Mercy is that the code?
https://sololearn.com/compiler-playground/c7r8P2S05tVx/?ref=app
+ 1
Yes
+ 1
What I need to do is to go the code get the link and post
0
Lothar
I don't know how to use the correct link
You can help me out