"naheed arafat" <[email protected]> wrote
1)
zip('How are you?'.split(' ')[::-1],'i am fine.'.split(' '))
[('you?', 'i'), ('are', 'am'), ('How', 'fine.')]
map(lambda i,j:(i,j),'How are you?'.split(' ')[::-1],'i am
fine.'.split(' '))
[('you?', 'i'), ('are', 'am'), ('How', 'fine.')]
Which one has better efficiency?
Why not just measure it with timeit?
2)
Is there any way easier to do the following?
input:
'How are you'
'I am fine'
output:
'you I are am How fine'
solution:
' '.join(reduce(lambda x,y:x+y, zip('How are you'.split('
')[::-1],
'I am fine'.split(' '))))
That depends on your efiition of easier
There are clearer solutions but they will be more verbose.
Do you measure "easiness" by readability, or by typing effort?
Or something else?
Alan G
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor