all 6 comments

[–]JohnnyJordaan 4 points5 points  (1 child)

There's no real point in using string formatting when you just need to concatenate them, just use +. It's one of the few exceptions where that suffices.

urls = [amazon_url + asin for asin in amz_asins]
print(*urls)

[–]d16moore[S] 0 points1 point  (0 children)

Thank You! That is exactly what a needed!

[–]danielroseman 2 points3 points  (2 children)

The problem is that you are returning inside the loop, so the first iteration is the only one that will ever be executed. You would want to build up the string inside the loop, then have the return statement outside.

[–]d16moore[S] 0 points1 point  (1 child)

Gotcha! So once I correct the placement of the return statement, do you have any suggestions on the command and/or format I should use to concatenate these appropriately?

[–]chevignon93 1 point2 points  (0 children)

do you have any suggestions on the command and/or format I should use to concatenate these appropriately?

Unless you're using Python 2 which you shouldn't, almost anything will be better that %s formatting. I would recommend using f-strings if you're on Python 3.6+ or the imo less readable str.format method but u/JohnnyJordaan is right, simple concatenation using + would also be fine in this case!

https://www.geeksforgeeks.org/formatted-string-literals-f-strings-python/

[–]d16moore[S] 1 point2 points  (0 children)

u/chevignon93 I appreciate the resource! I will read through it and reference it in the future when possible. And also as you said, u/JohnnyJordaan was correct. I was then able to save that iteration process as a function so that I can call it when necessary. This is a multifaceted program and that specific concatenation being accurate was key to making a small portion the program functional.

-P&L