Python +;的操作数类型不受支持:';功能';和';int';错误
我的代码:Python +;的操作数类型不受支持:';功能';和';int';错误,python,function,for-loop,Python,Function,For Loop,我的代码: 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 wh
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 counting函数中。我是python新手,不知道为什么会发生什么。感谢您的帮助:)您在
范围内使用的所有东西都是函数,而不是变量;您必须调用(添加调用参数)它们以获取其值,更改:
for i in range ( start_input, finish_input +1, universal_step):
至(带间距):
您在范围内使用的所有东西都是函数,而不是变量;您必须调用(添加调用参数)它们以获取其值,更改:
for i in range ( start_input, finish_input +1, universal_step):
至(带间距):
您可能想使用()
调用该函数。您的问题在于的_counting()
函数。您尝试添加finish\u input
和1
,即使1
是一个int,而finish\u input
是一个函数。不能将函数添加到数字中。您可能打算使用finish\u input()
调用您的函数,但我立即注意到的问题是i在范围内(开始输入,完成输入+1基本上,您试图向函数中添加一个整数,这是无效的操作。函数是一种执行操作的方法。整数就是一个整数。您还将返回
调用打印()
,执行一个或另一个操作,或者打印然后返回您可能想使用()
调用该函数。您的问题在于的计数()
函数。您尝试添加finish\u input
和1
,即使1
是一个int,而finish\u input
是一个函数。您不能将函数添加到数字中。您可能想用finish\u input()
调用您的函数,但我立即遇到的问题是在范围内的我(开始输入,结束输入+1基本上,您试图向函数中添加一个整数,这是无效的操作。函数是一种执行操作的方法。一个整数就是一个整数。您还将返回使用打印()
,执行一个或另一个操作,或者打印然后返回