這個程序是爲給出的整數和寫def函數。我的def函數代碼結構中有什麼錯誤
def find_sum_numbers(sample_list):
sum_numbers=0
for x in sample_list:
sum_numbers=sum_numbers+x
#return sum_numbers
print("The sum of the numbers is: ", sum_numbers)
主程序:
n=input("Please enter a number: ")
sample_list=range(1,n+1))
find_sum_numbers(sample_list)
輸出:
Traceback (most recent call last): File "D:/edX-courses/Python/programs/def sum of numbers.py", line 14, in <module>
sample_list=range(1,n+1) TypeError: must be str, not int