for example I don't know what this is called » [('cat', 'meow'), ('dog', 'ruff')]
if I try for l in [('cat', 'meow'), ('dog', 'ruff')]: print l I am using l for lady luck lucy not I for I or the number 1 + maybe even | pipe for smoking
it makes it like this ↴

('cat', 'meow')
('dog', 'ruff')

so I can now remove the square brackets but I want to make it liek this ↴

catmeow
dogrugg

if there are spaces in the words then I will put them there first before I begin but I would also like to know how to make it like this other way just incase I need in my future ↴

cat meow
dog ruff

and even like this ↴

cat, meow
dog,ruff

Recommended Answers

All 4 Replies

for example I don't know what this is called » [('cat', 'meow'), ('dog', 'ruff')]

It's called a list of tuples

so I can now remove the square brackets but I want to make it liek this ↴

catmeow
dogrugg

You can do something like this:

your_list = [('cat', 'meow'), ('dog', 'ruff')]
for tpl in your_list:
    print tpl[0]+tpl[1]

You can also use for animal, noise in instead of for tpl in. Then you can use animal and noise instead of tpl[0] and tpl[1] respectively.

commented: thanks :) +4

Many thanks for your response but unfortunately I cease to recall what this is for but it has renewed my learning interest in pythons again. :)

Another option ...

mylist = [('cat', 'meow'), ('dog', 'ruff')]
for tup in mylist:
    print(" ".join(tup))  # use "" for no space
commented: thanks :) +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.