我的代码:
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'error”,这在def计数中功能。我是python的新手,不知道为什么和发生了什么。感谢您的帮助:)
答案 0 :(得分:3)
您在range
中使用的所有东西都是函数,而不是变量;您必须致电(添加通话对象)以获取其价值,并进行以下更改:
for i in range ( start_input, finish_input +1, universal_step):
到(间隔PEP8):
for i in range(start_input(), finish_input() + 1, universal_step()):