I am unsure how to fix: 'TypeError: can only concatenate str (not "int") to str '

Question:

new_url = sync_url+'/'+uri+'/data'

I tried new_url = sync_url+'/'+uri+'/str(data)' but I keep getting the same error. I am confused which one is the int. I thought it was data but I keep getting a error code.

Asked By: Jay

||

Answers:

Either sync_url or uri are of int type.

To solve your issue, check the type of these variables, and for the int one, you will need to wrap it with str()

For example, if uri is of type int, the following solves the problem:

new_url = sync_url + '/' + str(uri) + '/data'
Answered By: Khalil
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.