Average JS enjoyer
Average JS enjoyer

Reputation: 98

Unsupported operand type(s) for +: 'function' and 'int' error

my code:

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.")

so without putting the code into cunks of functions it used to be fully functional, now all i get is a "Unsupported operand type(s) for +: 'function' and 'int' error" which is in the def counting function. im new to python and dont know why and whats happening. Thanks for any help :)

Upvotes: 0

Views: 1678

Answers (1)

ShadowRanger
ShadowRanger

Reputation: 155438

All the things you're using in your range are functions, not variables; you have to call (add call parens) them to get their value, changing:

for i in range ( start_input, finish_input +1, universal_step):

to (with PEP8 spacing):

for i in range(start_input(), finish_input() + 1, universal_step()):

Upvotes: 3

Related Questions