1import traceback
2
3dict = {'a':3,'b':5,'c':8}
4try:
5 print(dict[q])
6
7except:
8 traceback.print_exc()
9
10# This will trace you back to the line where everything went wrong.
11# So in this case you will get back line 5
12
13
1# taking input from the user
2try:
3 age = int(input("Please enter your age: "))
4 print(age)
5except:
6 print("please enter a number instead! ")
7 print('bye')
8
9
10# if you wanna ask their age until they enter the correct number use While Loop
11while True:
12 try:
13 age = int(input("Please enter your age: "))
14 print(age)
15 except:
16 print("please enter a number instead! ")
17 else:
18 break
19
20