fibonacci python using for loop code example

Example 1: how to create fibonacci sequence in python

#Python program to generate Fibonacci series until 'n' value
n = int(input("Enter the value of 'n': "))
a = 0
b = 1
sum = 0
count = 1
print("Fibonacci Series: ", end = " ")
while(count <= n):
  print(sum, end = " ")
  count += 1
  a = b
  b = sum
  sum = a + b

Example 2: fibonacci series for loop python

# # this is the fibonacci series by KV for for loop :)

n = int(input(":"))
for i in range(1,n+1):
    print(i, end = "")