Python while loop 🔄

preview_player
Показать описание
Python while loops tutorial example explained

#while loop = a statement that will execute it's block of code,
# as long as it's condition remains true

name = ""

while len(name) == 0:
name = input("Enter your name: ")

print("Hello "+name)

#python #while #loop

––––––––––––––––––––––––––––––
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
––––––––––––––––––––––––––––––
Рекомендации по теме
Комментарии
Автор

# while loop = a statement that will execute it's block of code,
# as long as it's condition remains true

name = ""

while len(name) == 0:
name = input("Enter your name: ")

print("Hello "+name)

BroCodez
Автор

Thank you for this video :)
This is my code:

a = input("Enter your name : ")
while len(a)==0 :
print("Try again")
a = input("Enter your name : ")
if len(a) != 0:
print("Hello" + " " + a)

lldgzmd
Автор

man, idk if u realise, but your work is rly helping a lot of people, just keep up the work(if u have the energy to do so), you are doing a hell of a job, even better than most profesors do :D

shamanul
Автор

Thankyou for this amazing playlist Bro.
Here is my code,
name = input("Enter your name: ")
while len(name) == 0:
print("Try again sir!!!")
name = input("Enter your name: ")
if len(name) != 0:
print(f"Hello {name.capitalize()}")

Sanjaykumar-bdds
Автор

Thank you for all your hard work.
Would love to see more python.

davehug
Автор

I understand the first way you wrote the code but I'm not sure how or why the second while not piece with name = None worked

Xoilen
Автор

Thank you very much, !!! I was struggling to understand this.

waooooooo
Автор

I had to pause the video and put "Dormammu, I've come to bargain!" in the infinite loop, because how could I not.

Reapster
Автор

I didn't understand when you use none and while not name ?

AhmedAli-nfjq
Автор

btw sir thank you for your free tutorial lessons it helps me alot

SniperMania
Автор

u seem 2 be such a nice guy, thanks for ur videos, ur doing a great job

iks_
Автор

thank you so much. how would you do it with floats and integers e.g. mass or height

headmanlesetlhe
Автор

# Updated example
user = None
business_name = None

while not user:
user = input("Enter your name: ")
while not business_name:
business_name = input("Enter your business name: ")

user = "Welcome to " + user + "'s "

if business_name == 'Feed and Seed':
print(user + business_name + "\n(Formally Chuck's)")
else:
print(user + business_name)

goo_tx
join shbcf.ru