Is there a way to print an int (score) inside of a string without getting an error?
score = 0
score = score + 1
print("Your score was ")
print(score)
print(" out of 5")That is the code i currently have, which printsOutput:Your score was
1
out of 5And when i change it to thisscore = 0
score = score + 1
print("Your score was " + score + " out of 5")I get the errorError:Traceback (most recent call last):
File "C:\Users\{USER}\Desktop\Python\game.py", line 115, in <module>
print("Congratulations! You scored " + score + " out of 5 points")
TypeError: must be str, not intIs there anyway to fix this? I thought about changing the score to a string in the beginningscore = "0"But that wouldn't work because when you get a question right, and use
score = score + 1You would get an error. Unless you use
score = score + "1"But then score would equal to "01" and not "1"
Self-taught HTML, CSS, Python, and Java programmer
