Skip to content

Instantly share code, notes, and snippets.

@rostyq
Created July 30, 2017 11:29
Show Gist options
  • Save rostyq/8cc49c24773ac5a599fcb248cfa7f165 to your computer and use it in GitHub Desktop.
Save rostyq/8cc49c24773ac5a599fcb248cfa7f165 to your computer and use it in GitHub Desktop.
def get_user_int(msg):
'''
Return integer from user.
:param msg:
:return user_input:
'''
user_input = input(msg)
try:
user_input = int(user_input)
except:
print("Something wrong...")
return user_input
def get_fibonacci(count=3):
"""
Return list with Fibonacci numbers
:param count:
:return fibonacci_list:
"""
i = 2
fibonacci_list = [1, 1]
while i < count:
fibonacci_list.append(sum(fibonacci_list[-2:]))
i += 1
return fibonacci_list
count = get_user_int("Input a count of Fibonacci numbers ->")
print(get_fibonacci(count))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment