[Tutor] change the position and updated
Peter Otten
__peter__ at web.de
Thu Apr 27 03:09:59 EDT 2017
Peter Otten wrote:
> Sarika Shrivastava wrote:
>
>> Input :
>> c=[(12,45),(1234,567),(12345,0),(678,123456)]
>>
>> #o/p==1425
>> #o/p==1526374
>> #0/p==102345
>> #o/p===617283456
<snip my hints>
> If that's not enough to get a working solution you may come back here once
> you have some code.
OK, won't happen. Here's what I had in mind:
$ python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from itertools import zip_longest
>>> c = [(12, 45), (1234, 567), (12345, 0), (678, 123456)]
>>> for a, b in c:
... pairs = zip_longest(str(a), str(b), fillvalue="")
... print("".join(x + y for x, y in pairs))
...
1425
1526374
102345
617283456
More information about the Tutor
mailing list