prakash v prakash v - 2 months ago 9
Python Question

range as input in python

this is a simple program for Fibonacci series . its running perfectly for fixed range. but i would like to know is it possible to get range as input? if so please let me know the syntax to get range as input.

xx=0

x=float (raw_input("enter the starting number:"))

r1=xx+x

print r1

r2=r1+x

print r2

r3=r1+r2

print r3

for i in range(10):

r4=r2+r3

print r4

r2=r3

r3=r4


""" looking for answers"""

Answer

Do it like you asked for the starting number:

number_of_outputs = int( raw_input('Enter the number of outputs: '))

#Your code goes here

for i in range(number_of_ouputs):

    #More code goes here