I got the tuple -
Result = [
('80407', 'about power supply of opertional amplifier', '11 hours ago'),
('80405', '5V Regulator Power Dissipation', '11 hours ago')]
I want to iterate over the tuples and separate the items in the tuples by ;
.
The output should be as follows -
80407;about power supply of opertional amplifier;11 hours ago
I tried the following:
for item in zip(*Result):
print(*item[0], end=';')
Which gave me the result -
8 0 4 0 7;a b o u t p o w e r s u p p l y o f o p e r t i o n a l a m p l i f i e r;1 1 h o u r s a g o;
and
for item in Result:
print(*item[0], end=';')
Which gave me -
8 0 4 0 7;8 0 4 0 5;
How to properly iterate over a tuple?
Join the items in the tuple with a ;
, and join the resultant string in the outer list with another separator, perhaps a newline \n
s = '\n'.join(';'.join(lst) for lst in Result)
print(s)
The output will be
80407;about power supply of opertional amplifier;11 hours ago
80405;5V Regulator Power Dissipation;11 hours ago
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With