Learn Python Programming - 21 - While Loops

preview_player
Показать описание

Let's cover while loops in Python. They are useful when you don't know how long something is going to take to end. Whereas you should use for loops when you know when something should end. Ex: While you are not tired... Keep going. While the user wants to keep playing... Keep playing. For 10 times, do pushups. For 55 times, do jumping jacks. Hopefully, you get a little bit of an idea. ...
...
★☆★ FREE Lesson 1: The Most Important Thing For a Successful Programmer★☆★

Enroll for coding exercises, projects, tutorials, and courses...
Clever Programmer
Snapchat ► Rafeh1
Рекомендации по теме
Комментарии
Автор

Love this man!!!!
I just did something myself, and It felt so good
count = 100

while count > 0:
print (count)
count = count - 1
if count == 0:
print ("Boooyah!")

raghavanand
Автор

count = 0
while count > 0:
print(count)
count = count - 1
if count == 0:
print("BLAST

I think this is easier. I really love your lectures.

talesofeer
Автор

I've watched all your python tutorials and haven't seen anyone who explains it better than you

soldiergaming
Автор

count = 100 # this also works
while count>=0:
if count>0:
print(count)
else:
print("blast off")
count = count - 1

ezra
Автор

count = 100
while count > 0:
print(count)
count = count - 1
print(count)
if (count == 0):
print("Blast off!")





WOW I learned a lot from this simplke code! I forgot turn this sign around: from "<" to ">"

cgd
Автор

I liked the way u related while loops with push-ups

nevon_jam
Автор

count = 100
while count > 0:
print(count)
count = count - 1
if count<=0:
print("blast off")

satheeshkumar
Автор

you can also write like this
m = int(input("Enter a number\n"))
while 0 < m:
print(m)
m -= 1
print("yes i know while loop")

suryanshporwal
Автор

I just don't understand how someone could possibly enjoy doing I'm only doing this for a class that I have to take, and I hate my life hahahaha. But hey, to each their own. Anyways, thanks for the help man!! You post awesome content!

jtak
Автор

I am new to coding but a really good hint for new users like me. spacing after : counts. I ran a while loop that had a infinite loop because I didn't space things properly.

sgtkeebler
Автор

count = 0
count = 100
while count > 0:
print(count)
count = count - 1
if count == 0:
print('blast off')

lishengyang
Автор

while count>1:
print(count)
count=count-1
while count==1:
print('BLAST OFF')
break

hhinfosystemspvt.ltd.
Автор

count = 100
while 0 < count <= 100:
print(count)
count = count - 1
if count == 0:
print("Blast off")

#I didn't make count <= 0, but still got blast off in the end. (I am using Pycharm)

tauhidurrahman
Автор

count = 100
while count > 0:
print(count)
count -= 1
if count == False:
print("Blast off!")

scott
Автор

count = 99
while 0 < count < 100:
print(count)
count -= 1

print('Blast off')

Moises-Devzz
Автор

this is how I did mine and it worked

number = 100
while number != 0:
print(number)
number -= 1
if number == 0:
print("blast off")

muradelmissalati
Автор

count = 100
while count > 0:
count = count - 1
if count == 0:
print("Blast off!")
else:
print(count)

sdr
Автор

Thanks for the explanation. What's the difference between the following two answers? The output is 0 to 9. The other one is 1 to 10. Why is that?

count = 0
while count < 10:
print(count)
count = count + 1

vs.

count = 0
while count < 10:
count = count + 1
print(count)

francescowang
Автор

I ran the code :
count = 100
while count >= 0:
if count == 0:
print('Blast off!')
else:
print(count)

count = count - 1

But i get...
SyntaxError: multiple statements found while compiling a single statement

Dezzymodel
Автор

my_energy = 100


while my_energy > 90:
print "Do Pushups"
my_energy -= 1

palestinian