-2

i'm trying to code a game but it keeps popping up with can only concatenate str (not "int") to str and i tried print('sample text' + variable + 'sample text')

RonaB
  • 5
  • 2

2 Answers2

2

You can either cast to str or use an f-string (format string).

print('sample text' + str(variable) + 'sample text')

or

print(f'sample text {variable} sample text')

will-hedges
  • 1,254
  • 1
  • 9
  • 18
0

Try to wrap it with string using print(str(variable)).

Renee
  • 90
  • 2
  • 10