Skip to content

PEP style and fixed exception on input other and integer type #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions dynamic_programming/fibonacci.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""
This is a pure Python implementation of Dynamic Programming solution to the fibonacci sequence problem.
"""


class Fibonacci:

def __init__(self, N=None):
if N:
N = int(N)
self.fib_array = [0] * (N + 1)
self.fib_array[0] = 0
self.fib_array[1] = 1
Expand Down Expand Up @@ -43,12 +46,13 @@ def get(self, sequence_no=None):
"\n********* Enter different values to get the corresponding fibonacci sequence, enter any negative number to exit. ************\n")
while True:
print("Enter value: ", end=" ")
i = eval(input())
if i < 0:
print("\n********* Good Bye!! ************\n")
break
fib.get(i)
except NameError:
print("\nInvalid input, please try again.")
try:
i = eval(input())
if i < 0:
print("\n********* Good Bye!! ************\n")
break
fib.get(i)
except NameError:
print("\nInvalid input, please try again.")
except NameError:
print("\n********* Invalid input, good bye!! ************\n")