I am writing a temperature converter for fun and everything seems to be working except I am getting a 'TypeError: Can't convert 'float' object to str implicitly' message. From what I can tell I am converting it to a string after the fact, can anyone tell me what I am doing wrong?
I looked this this question previously "Can't convert 'float' object to str implicitly"
def tempconverter(startType,Temp):
#conversion types: c -> f c-> K , f -> c, f -> k, k -> c, k -> f
# maybe have them select only their beginning type then show
# all temp types by that temperature
if startType[0].lower() == 'c':
return ('Your temperature ' + Temp +'\n'
+ 'Farenheight: ' + ((int(Temp)*9)/5)+32 + '\n'
+ 'Kelvin: ' + str((Temp+ 273.15)) ## I get the error here ##
)
elif startType[0].lower() == 'f':
#commented out until first is fixed
#return ((int(Temp)-32)*5)/9
return Temp
elif startType[0].lower() == 'k':
return Temp
print('Welcome to our temperature converter program.')
print('''Please enter your temperature type:
C = Celsius
F = Farenheight
K = Kelvin''')
sType = input('> ')
print('Please enter the temperature you wish to convert.')
sTemp = input('> ')
print(tempconverter(sType,sTemp))