I am having issues with the second to last 'elif' statement, I am getting the concatenation error with str and integers-> any explanation to why this is? My understanding is that I am adding a string "R" to the empty string next_row.
Specifically the error is "can only concatenate str (not "int") to str"
def triangle(row):
next_row = ''
for i in row:
if i == 'G' and (i + 1) == 'B':
next_row += 'R'
elif i == 'G' and (i + 1) == 'R':
next_row += 'B'
elif i == 'R' and (i + 1) == 'B':
next_row += 'G'
elif i == 'R' and (i + 1) == 'G':
next_row += 'B'
elif i == 'B' and (i + 1) == 'G':
next_row += 'R'
elif i == 'B' and (i + 1) == 'R':
next_row += 'G'
print(type(next_row))
return None
triangle("BRGGBRG")
question from:https://stackoverflow.com/questions/65873000/getting-an-issue-when-adding-strings