File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 11"""
22This is a pure Python implementation of Dynamic Programming solution to the fibonacci sequence problem.
33"""
4+
5+
46class Fibonacci :
57
68 def __init__ (self , N = None ):
79 if N :
10+ N = int (N )
811 self .fib_array = [0 ] * (N + 1 )
912 self .fib_array [0 ] = 0
1013 self .fib_array [1 ] = 1
@@ -43,12 +46,13 @@ def get(self, sequence_no=None):
4346 "\n ********* Enter different values to get the corresponding fibonacci sequence, enter any negative number to exit. ************\n " )
4447 while True :
4548 print ("Enter value: " , end = " " )
46- i = eval (input ())
47- if i < 0 :
48- print ("\n ********* Good Bye!! ************\n " )
49- break
50- fib .get (i )
51- except NameError :
52- print ("\n Invalid input, please try again." )
49+ try :
50+ i = eval (input ())
51+ if i < 0 :
52+ print ("\n ********* Good Bye!! ************\n " )
53+ break
54+ fib .get (i )
55+ except NameError :
56+ print ("\n Invalid input, please try again." )
5357 except NameError :
5458 print ("\n ********* Invalid input, good bye!! ************\n " )
You can’t perform that action at this time.
0 commit comments