Reputation: 3
I tested out the string.join()
method on a few lines of code:
a = 1
b = 1
c = 0
superpower = []
if a == 1:
superpower.append("flying")
if b == 1:
superpower.append("soaring")
if c == 1:
superpower.append("high")
", ".join(superpower)
print superpower
but the result always comes back as just a regular list, not a string. How can I fix this? I'm new to python, and would appreciate the help.
Upvotes: -1
Views: 51
Reputation: 310227
", ".join(superpower)
returns a string, it doesn't convert the input iterable into a string. You aren't doing anything with that return value:
superpower_str = ', '.join(superpower)
print(superpower_str)
is probably what you want.
Upvotes: 5