0

I'm trying to create a URL to access data. Given initial an initial Lat/Lon that will vary from user to user, I want this code to spit out a URL appropriate to access the data.

I keep getting this error: "cannot concatenate 'str' and 'tuple' objects"

Any idea on how to fix this?

1 Answer 1

3

Your indices=.... line is not creating a string, it's creating a tuple

If I do

var = 1, 2, 'hello'

var is not a concatenation of all those things. It's the tuple: (1,2,'hello')

If you want indices to be a str, with all of those things concatenated you can add the following:

indices_str = ''.join([str(x) for x in indices])

Then you can safely concatenate path and indices_str by adding them together

Sign up to request clarification or add additional context in comments.

2 Comments

Or replace the commas in the definition of indices with + to concat them all into a string.
That assumes that the variables (like lat_min) are already stringified

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.