Saturday, September 9, 2017

Python: control statement

scope=[1,2,3]
for x in scope
   print(x)
   break
else:
   print("Perfect")

Output:
1

break를 지우면,
Output:
1
2
3
Perfect


while condition:
   repeating_code
   continue   # return to while condition
   ...
   break       # exit while condition


No comments:

Post a Comment