+ 1
I have problem understanding while loop
Can someone help me out with it?
16 Respostas
+ 8
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
What I need to do is to go the code get the link and post
+ 2
Aleksei Radchenkov thanks
Corrected it already
+ 2
A while loop keeps running as long as a condition is True.
Simple example:
count = 1 # start at 1
while count <= 5: # repeat while count is less than or equal to 5
print("Number:", count)
count = count + 1 # increase count by 1 each time
+ 2
SAIFULLAHI KHAMISU this is not a code advertisement thread. Please use the six threads available.
https://sololearn.com/compiler-playground/WvG0MJq2dQ6y/?ref=app
+ 2
I am Fake ,
you are at the right place here. sololearn is a `self-learner` platform. you can learn from the supplied tutorials at your own pace.
since you have already started with 2 tutorials - you could continue with these.
if it is not what you have expected, the following may help you to decide:
> if you are interested in ``web development``, you could start with the tutorial *web development*. it is a compilation of some individual tutorials: *introduction to html*, *introduction to css*, *introduction to javascript*.
but you can also start with the mentioned independent tutorials.
> if you are interested in app development, you can try *java*, *c*, *c#*, *c++*. just use the *introduction to ...* of the mentioned courses.
> if you are not quite sure and you want just getting into coding, you can start with the tutorial *introduction to python*.
if you get stuck somewhere in your learning journey, you can post a question here.
+ 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
Lothar
I don't know how to use the correct link
You can help me out
+ 1
Mercy is that the code?
https://sololearn.com/compiler-playground/c7r8P2S05tVx/?ref=app
+ 1
Yes
+ 1
Sure! A while loop is a way to repeat something over and over again as long as a specific condition is true.
Think of it like this:
"If this is still true, keep doing it."
As soon as the condition is no longer true, it stops.
For example, imagine you're filling a glass of water.
You keep pouring while the glass is not full.
Once it's full, you stop â thatâs how a while loop works.
If you share what exactly confuses you, I can explain more clearly
+ 1
https://sololearn.com/compiler-playground/cbG225pbu29M/?ref=app
+ 1
I am beginer and not understand anything here