Help with returning variables - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help with returning variables

vbchguy87vbchguy87 Posts: 4Member
Hello i am a n00b with python i need help. i cannot get the code below to work


def main():
t_s = input('what were the t_s?')
s_t(t_s)
c_t(t_s)
t_t(s_t,c_t)
print 'your t_t ', t_t


def s_t(value):
return float(value)*2

def c_t(value):
return float(value)*3


def t_t(val1,val2):
t_t = val1+val2


main()

then i run it and get the error
TypeError: unsupported operand type(s) for +: 'function' and 'function'



HELP


Comments

  • bubbatremellbubbatremell Posts: 39Member
    : def main():
    : t_s = input('what were the t_s?')
    : s_t(t_s)
    : c_t(t_s)
    : t_t(s_t,c_t)
    : print 'your t_t ', t_t
    :
    :
    : def s_t(value):
    : return float(value)*2
    :
    : def c_t(value):
    : return float(value)*3
    :
    :
    : def t_t(val1,val2):
    : t_t = val1+val2

    : then i run it and get the error
    : TypeError: unsupported operand type(s) for +: 'function' and
    : 'function'

    t_t(s_t,c_t) is the problem. s_t and c_t are functions. If you want to call them, use t_t(s_t(x), c_t(x)). Your line is passing the actual functions as parameters-- not the return values.

    Also, s_t and c_t return values, but you aren't storing them anywhere. You might try either
    s = s_t(t_s)
    c = c_t(t_s)
    t_t(s, c)
    or
    t_t(s_t(t_s), c_t(t_s))

  • vbchguy87vbchguy87 Posts: 4Member
    Thanks a lot got it working
Sign In or Register to comment.