當我運行這個時,我得到以下類型不匹配錯誤,我不知道為什么var被認為是一個字符串而不是一個int。我在這里錯過了什么嗎?`Traceback (most recent call last): File "main.py", line 5, in <module> test.assert_equals(productFib(4895), [55, 89, True]) File "/home/codewarrior/solution.py", line 7, in productFib while var <= prod:TypeError: unorderable types: str() <= int()`def productFib(prod): # create Fibonacci array var = 0 elem = 0 boo = False while var <= prod: var = fib(elem)*fib(elem+1) if var == prod: boo = True elem += 1 return [fib(elem), fib(elem+1), boo]# function to return what the nth fibonacci number is def fib(n): if n < 0: return "Incorrect input" elif n == 1: return 0 elif n == 2: return 1 else: return fib(n-1)+fib(n-2)
添加回答
舉報
0/150
提交
取消