[Tutor] change the position and updated
Peter Otten
__peter__ at web.de
Wed Apr 26 05:18:00 EDT 2017
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
>
> Question explanation:
>
> in list c we have some tuples so I need to take tuple value one by one and
> change the position of value like wise
>
> first tuple value (12 ,45) then then 1 we pick up append on 4 So it make
> 14 after tat 2 we pick and append on 5 so 25 then final o/p is 1425 ,
>
> Please check output also...
That looks *a* *lot* like homework, so you're supposed to find the answer
yourself. A few hints:
- splicing the digits will become easier if you convert the numbers to
strings first.
- have a look at itertools.zip_longest() (you'll need to specify a
fillvalue. Which?)
- you can build a string from a sequence of strings with "".join(strings).
If that's not enough to get a working solution you may come back here once
you have some code.
More information about the Tutor
mailing list