1

I am getting an error message from a simple looping exercise.

for i in range( 1, 4 ) :
    for j in range( 1, 4 ) :
        print( 'Running i=' + i + 'J=' + j)

Error message: print( 'Running i=' + i + 'J=' + j) TypeError: can only concatenate str (not "int") to str

1 Answers1

0

You can't combine an int and a string. i and j are ints so they need to be cast to strings to be concatenated with the other parts of your string.

You need to cast it to a string:

for i in range(1, 4):
    for j in range(1, 4):
        print('Running i=' + str(i) + 'j=' + str(j))
C. Fennell
  • 992
  • 12
  • 20