-2

I'm trying to write a basic Python RPG for my friend, and I'm trying to make a stat generator. From what I learned in classes, I'm supposed to print('Your ability score in this is ' + var1 + '.')

Here's the entire code block where I'm getting the error.

Your elemental attack is '''+ elematk + '''.''')

And the error I'm getting is

  File "/Users/data censored/Desktop/Basic RPG.py", line 24, in <module>
    Your elemental attack is '''+ elematk + '''.''')
TypeError: can only concatenate str (not "int") to str

Maybe I'm just bad at this. I looked at another answer saying that commas separate a string and a var, but that didn't work either.

TheMP8
  • 1
  • 3

1 Answers1

0

Your elematk variable is an integer, hence you can't concatenate it with a string. You can case it to a string type by doing str(elematk)

Try doing something like:

print('elemental attack is '''+ str(elematk)+ '''.''')
Akshath Mahajan
  • 248
  • 2
  • 11