Skip to content

Commit 259cc59

Browse files
committed
Add error and exceptions
1 parent 30f87f7 commit 259cc59

File tree

2 files changed

+9
-0
lines changed
  • errors_and_exceptions

2 files changed

+9
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
while True:
2+
try:
3+
a = int(input('key in any integer>> '))
4+
break
5+
except ValueError:
6+
print('\x1b[31mInvalid number!\x1b[0m')
7+
8+
print(f'number: {a}')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
raise ValueError

0 commit comments

Comments
 (0)