PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def isInteger (x):
try:
x = int(x)
except:
return False
else:
return True
def isAcceptableInt (x):
if (not isInteger(x)):
return False
else:
if (int(x) < 1):
return False
else:
return True
def countDigits (x):
val = 0
while (x > 0):
val += 1
x = x//10
return val
print("Welcome to the 3-sum-triangle generator!")
bound = input("Please input an integer no smaller than 1: ")
while (not isAcceptableInt(bound)):
print("Whoops! That's not an integer no smaller than 1.")
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run