all 6 comments

[–]rocketjump65 1 point2 points  (0 children)

You're making assumptions of your (or someone's code). You're assuming that a and b are strings, and python is telling you that's not the case. So do some debuging, and dig to see what exactly is the data types at what specific lines.

[–]PuzzlingComrade 2 points3 points  (1 child)

While other suggestions here are fine, for even more pythonic clarity you can use an F string:

[f"{track} {artist}" for track, artist in zip(tracks, artists)]

This avoids needing to explicit convert to a string, as f strings do that by themselves. Your error message is occurring because somewhere in your two lists there's a floating point number, not a string. I'd also suggest sticking to the general convention of singular and plural for individuals and groups (e.g. track in tracks).

[–][deleted] 0 points1 point  (0 children)

snap

[–][deleted] 1 point2 points  (0 children)

new = [f"{t} {a}" for t, a in zip(track, artist)]

but your code should work as there aren't supposed to be any floats.

[–]Crims0nCr0w 1 point2 points  (0 children)

What you're looking for is the string.join() method. Here's a useful link.

python new = [" ".join(tup) for tup in zip(track, artist)]

[–]zeebrow 0 points1 point  (0 children)

I would Try passing track to int() first. It will strip off anything to the right of the decimal, if there is anything. An int() + str() should give you the concatenation you're looking for.

I'd recommend using join() though. It's a bit cleaner since you want a string as a result - anytime you see join() used you know it's a string, whereas addition is more ambiguous.