For Loops

preview_player
Показать описание
MIT 6.0001 Introduction to Computer Science and Programming in Python, Fall 2016
Instructor: Dr. Ana Bell

This in-class question demonstrates For Loops and Break statements in Python.

License: Creative Commons BY-NC-SA
Рекомендации по теме
Комментарии
Автор

after breaking from the if code block why didnt the value of i incremented, for loop was still going on

nitinsaini
Автор

Output would be 1 loop only iterate once

zis
Автор

mystock = 0
for s in range (5, 11, 2):
mystock += s
if mystock == 11:
break
mystock +=1
print(mystock)

output 21

muthabukujohn