• Register
1 vote
50 views

Problem:

 

if verb == "stoke":

        if items["heat"] >= 1:
            print("going to stoke the furnace")

            if items["coal"] >= 1:
                print("successful!")
                temperature += 250 
                print("the heat is now " + (temperature) + "degrees!")
                           
            else:
                print("you can't")

        else:
            print("you have nothing to stoke")

 

I don’t know know what’s wrong with my code. The resulting error comes up as the following:

Traceback(most recent call last):
       File "C:\Users\User\Documents\Python\smelting game 0.3.1 build 
       incomplete.py"
     , line 227, in <module>
         print("the heat is now " + (temperature) + "degrees!")
    TypeError: must be str, not int

I must recognize your effort.

12 7 7
15,250 points

1 Answer

1 vote

Solution:

Python can't automatically convert integer variable to string. You need to explicitly convert future variable to str.

So,

print("the heat is now " + str(temperature) + "degrees!")

cast this portion to str. Then the code should execute with no errors.

 

13 9 6
94,240 points

Related questions

1 vote
1 answer 55 views
55 views
Problem: I wrote a program in which gives me the following error : TypeError: startswith first arg must be bytes or a tuple of bytes, not str The program I wrote is: def allFasta(filename): xd = open(filename, 'yb') headers = "" sequence = "" while True: ... ("youn.xd") Why is this type error message is appearing for this program. Is there any problem with my programs arguments? Thanks in advance.
asked Jun 11 samhaz 5k points
1 vote
3 answers 551 views
551 views
Problem : I'm a newbie with Python's arrays and I don't understand how I can avoid below error: python typeerror: list indices must be integers or slices, not str
asked Oct 21, 2019 peterlaw 6.9k points
0 votes
1 answer 1.5K views
1.5K views
Problem : I am facing the issue in passing a function as a parameter to another function as follows typeerror: int() argument must be a string, a bytes-like object or a number, not 'nonetype'
asked Nov 18, 2019 peterlaw 6.9k points