【发布时间】:2017-10-15 20:21:55
【问题描述】:
我想我想做的是从定义的列表中显示一个选择部分。目前这是我正在使用的:
#fibonacci sequence algorithm, user stops by either
#entering a maximum Fibonacci value not to exceed or
#a total count that the sequence of numbers must not
#exceed. Use a loop that allows User to repeat program
#as much as they wish, asking if they would like to
#repeat the program each time. Validate that User input
#is either a yes or a no and only allow User to continue
#once a correct response has been given.
import array
array.listOfFibSeq = ['0','1','1','2','3','5','8','13','21','34','55','89','144','...']
startingNumber = ''
endingNumber = ''
continueYes = ''
def getStartingNumber():
print('Please enter a valid starting number of the Fibonacci Sequence')
print(listOfFibSeq)
startingNumber = input()
def getEndingNumber():
print('Please enter a valid ending number the the Fibonacci Sequence')
print(listOfFibSeq)
endingNumber = input()
我不确定该怎么做,但我相信我正在尝试在斐波那契数列中显示(例如)3 到 89 或执行以下操作:
lsitOfFibSeq.remove(<3) and listOfFibSeq.remove(>89)
或者我应该尝试使用 for 循环显示 Fib 序列的范围?
【问题讨论】:
标签: python python-3.x append fibonacci