We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7de7c50 commit 4aace21Copy full SHA for 4aace21
Medium-Questions/70-Pascals-triangle/Python/app.py
@@ -32,16 +32,22 @@ def main():
32
global data
33
data = []
34
35
- x = int(input("level: "))
+ while True:
36
+ try:
37
+ x = int(input("level: "))
38
+ except ValueError:
39
+ continue
40
+ else:
41
+ break
42
plevel = 0
43
for each in range(x):
44
data.append(makeThisLevel(each))
45
46
max_len = len(data[-1])
- for i in data:
- for j in i:
- space = max_len - len(i)
- print(" " * (space // 2), j, " " * (space //2), end="")
47
+ for index, i in enumerate(data):
48
+ space = max_len - len(i)
49
+ print(f"[{index}]", end=" ")
50
+ print(" " * ((space // 2 +1 )), "".join(i), " " * (space //2 +1), end="")
51
print("")
52
53
0 commit comments