First post!
I am doing a basic python program, this stuff is very advanced for me :D, and I want to strip off the characters ' , ()
from a tuple when it is printed. What I have, that prints the list out without stripping, is:
view = map(str, listplanets)
print("\n".join(view))
"listplanets" is the name for the tuple, though you guys probably know this XD. I tried view = map(str, listplanets).strip("\"',")
and I have tried moving this strip command to every place I could think of. I always get an error saying that the map does not have the attribute strip. If I convert the tuple into a string like so view(str(listplanets))
it will print out each character on a separate line rather than each tuple item. This is the output that I get:
('Mercury', 0.378)
('Venus', 0.907)
('Mars', 0.377)
('Io', 0.1835)
('Europa', 0.1335)
('Ganymede', 0.1448)
('Callisto', 0.1264)
It would be greatly appreciated if someone can answer this for me :).
lines = ['{} {}'.format(planet, n) for planet, n in listplanets]
print('\n'.join(lines))