• Register
1 vote



if verb == "stoke":

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

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

            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 
     , 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

Please log in or register to answer this question.

1 Answer

1 vote


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


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

0 votes
1 answer 52 views
I was looking for a way to run an external process from python script and print its stdout messages during the execution. The code below works, but prints no stdout output during runtime. When it exits I am getting the following error: sys.stdout.write(nextline) TypeError:must ... .stdout.write(nextline) sys.stdout.flush() output = p.communicate()[0] exitCode = p.returncode I am using python 3.3.2
asked Oct 24, 2020 psandprop 2.4k points
0 votes
1 answer 3 views
Problem: On the last line, I got this error: builtins.TypeError: must be str, not bytes File "C:\PythonExamples\XmlReportGeneratorExample.py", line 29, in <module> doc.write(outFile) File "c:\Python32\Lib\site-packages\lxml\etree.pyd", line 1853, in lxml.etree._ElementTree.write (src/ ... etree.c:89527) I've installed Python 3.2, and I've installed lxml-2.3.win32-py3.2.exe. On Python 2.7 it works.
asked Jan 9 Mashhoodch 5.7k points
0 votes
1 answer 28 views
Problem: Hello! I am a beginner. I just moved from Java to Python programming just recently. I am learning the syntax of Python. I am trying to print the multiplication table using the while loop. I have written the following program in an attempt to do that: number ... to str implicitly I do not have any clue regarding this error. Can anybody here help me solving this error? I would be thankful.
asked Jan 8 Code Learner 5.5k points
0 votes
1 answer 8 views
Problem: Hi! I am new to the world of programming. I am trying to multiply two numbers that will be entered by the user. I wrote the following program: number1 = input("Enter first number: ") number2 = input("Enter second number: ") print(number1," * ",number2," = ", ... = ",number1*number2) TypeError: can't multiply sequence by non-int of type 'str' I have no idea what I am doing wrong. Any help?
asked Dec 21, 2020 Code Learner 5.5k points
0 votes
1 answer 5 views
Problem: I am a newbie to the world of Python, and I am so confused about the data types in Python. I am trying to run the following program: obtained_marks = input("Enter the marks your child obtained: ") total_marks = 100 difference = total_marks - ... cannot see any evident reason for this error. I cannot identify where I am trying to subtract a string from an integer. Any helper?
asked Dec 17, 2020 Code Learner 5.5k points
0 votes
1 answer 5 views
Problem: Hello! I am new to programming and I am trying to run following code: def division(number): if(number/4 >= 1): print("Divisible by 4") else: print("Not divisible by 4") dividend = input("Enter dividend: ") division(dividend) What I am trying to do is ... 'int' I cannot see any obvious reason of this error. If any of you could identify the reason, it would be very helpful for me. Thanks!
asked Dec 17, 2020 Code Learner 5.5k points
0 votes
1 answer 18 views
Problem: I have this python program that adds strings to integers: a = raw_input("Enter a: ") b = raw_input("Enter b: ") print "a + b as strings: " + a + b a = int(a) b = int(b) c = a + b str(c) print "a + b as integers: " + c I get this error: Python: TypeError: cannot concatenate 'str' and 'int' objects How can I add strings to integers?
asked Jan 7 Mashhoodch 5.7k points
1 vote
1 answer 305 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, 2020 samhaz 5k points
1 vote
3 answers 617 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