Wednesday, July 10, 2019

For if else break example

Script

#!/usr/local/bin/python3.6

magicnumber = 23

for n in range(100):
  if n is magicnumber:
  print(n, " is the magic number.")
  break
  else:
  print(n)

Execution

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23  is the magic number.


No comments:

Post a Comment