【发布时间】:2018-11-06 21:03:58
【问题描述】:
我的代码:
def start_input():
start = int(input("\nAt what number shall we start, master? "))
return start
def finish_input():
end = int(input("\nwhen shall i finish, master? "))
return end
def step_input():
rise = int(input("\nby what ammount shall your numbers rise, master? "))
return rise
def universal_step():
rise = 3
return rise
def the_counting():
print("your desired count: ")
for i in range ( start_input, finish_input +1, step_input): #can be also changed for automated step
return print(i, finish_input =" ")
def main():
start_input()
finish_input()
step_input() #This can be changed for the universal_step function for no input if wanted
the_counting()
main()
input("\n\nPress the enter key to exit.")
所以没有将代码放入以前功能齐全的函数中,现在我得到的只是“+ 的不支持的操作数类型:'function' 和 'int' 错误”,它在 def 计数中功能。我是 python 新手,不知道为什么以及发生了什么。感谢您的帮助:)
【问题讨论】:
-
你可能想调用那个函数,使用
()。 -
您的问题在于您的
the_counting()函数。您尝试添加finish_input和1,即使1是一个int 而finish_input是一个函数。您不能将函数添加到数字。您可能打算使用finish_input()调用您的函数 -
我立即想到的问题是 i in range ( start_input, finish_input +1 基本上,您正在尝试将整数添加到函数中,这不是有效的操作。函数是一种做某事的方法。整数就是整数。
-
你也是
returnprint(),做一个或另一个,或者打印然后返回