Python While loop - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Python While loop - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Saturday, December 1, 2018

Python While loop

Python While loop



While Loop

A while loop repeats a block of code as long as a certain condition is true.
#A simple while loop
current_value = 1
while current_value <= 5:
 print(current_value)
 current_value += 1


#Letting the user choose when to quit
msg = ''
while msg != 'quit':
 msg = input("what's your message? ")
 print(msg)

Screenshot

while loop
 

No comments:

Post a Comment

Post Top Ad