How to call a function within another function in Python -


as can see trying make currency converter. trying if number "1" inputted go function 'gbp'. works fine until gets asks how money want convert (line 25). when type in value , press enter comes traceback error, telling me of lines 33, 5, , 29 have "unsupported operand type(s) +: 'float' , 'str'".

this code:

def start(): print("hello , welcome limited currency converter!\nin converter, number '1' means pounds sterling, number '2' means dollars, '3' means euros , '4' means japanese yen.") = input("which currency wish convert from?\n") if == ("1"):     gbp()     return elif == ("2"):     usd()     return elif == ("3"):     euro()     return elif == ("4"):     yen()     return else:     print("that not valid input. please restart program , input either '1', '2', '3' or '4'!") return start  def gbp(): gbpto = input("which currency converting into?\n") if gbpto == ("1"):     print("you converting pounds sterling pounds sterling... there no conversion needed!") elif gbpto == "2":     num = float(input("please type in amount of pounds sterling wish convert dollars.\n"))     calc = num * 1.55     float(calc)     calc = round(calc, 2)     print(num + " pounds sterling in dollars $", + calc)     return start() 

i'd appreciate help. thanks

you're trying add float , string. python doesn't know kind of adding want do, need convert num , calc strings before concatenating string:

print(str(num) + " pounds sterling in dollars $" + str(calc)) 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -