Hi all,
I want to make tuples of the elements of a list like this.
l = [1, 2, 3]
Wanted tuples:
(1, 2)
(2, 3)
(3, None)
I can get the first two tuples using zip(l, l[1:]). How do I get the
last one?
Many thanks in advance,
Nicky 2 1313
Nickolay Kolev wrote: I want to make tuples of the elements of a list like this.
l = [1, 2, 3]
Wanted tuples:
(1, 2) (2, 3) (3, None)
I can get the first two tuples using zip(l, l[1:]). How do I get the last one? l = [1, 2, 3] zip(l, l[1:]+[None])
[(1, 2), (2, 3), (3, None)]
Use map( None, l, l[1:] )
HTH,
Mike
Nickolay Kolev wrote:
.... Wanted tuples:
(1, 2) (2, 3) (3, None)
I can get the first two tuples using zip(l, l[1:]). How do I get the last one?
....
_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thomas Philips |
last post by:
I have been playing around with reading strings with embedded escape
sequences from files both using readline() and codecs.open() and have
a question.I create a file "test.txt" with exactly one...
|
by: Minho Chae |
last post by:
Hello, python lovers!!
I'm trying to create combinations of sequences.
For example, if the sequence is 'acgt' and the length is 8,
then I would like to have 4^8 results such as
'aaaaaaaa',...
|
by: temp |
last post by:
Hi All,
I wonder could someone help me with this?
What I want to do is search through a list of letters and look for
adjacent groups of letters that form sequences, not in the usual way of...
|
by: Rick Brandt |
last post by:
If you examine the complete XML below you will see an element "Notes"
consisting of...
<Notes>test replace test&replace</Notes>
As you can see I have properly (I think) escaped the ampersand...
|
by: Roggey |
last post by:
Hello
I'm using System.Windows.Forms.Label and I want to add some text, where
one or more words are bold or italic.
I tried it with html tags but does not work. Somewhere i did read it
should...
|
by: Ryan |
last post by:
Hi,
I am confused with how NetworkStream works.
My application needs to handle heavy requests sent through TCP socket
connection. I use NetworkStream.Read method to get the stream...
|
by: Philip Wagenaar |
last post by:
Framework 1.1
I want to start AcrobatReader to print a printjob under a specific username
(so that the owner of the printjob is not the username of the application
that the .net application runs...
|
by: ABCL |
last post by:
Hi All,
I am working on the situation where 2 different
Process/Application(.net) tries to open file at the same time....Or one
process is updating the file and another process tries to access...
|
by: Anthra Norell |
last post by:
Hi,
I keep working around a little problem with unpacking in cases in which I don't know how many elements I get. Consider this:
def tabulate_lists (*arbitray_number_of_lists):
table = zip...
|
by: krikaran adel |
last post by:
Hi,
First of all I found your tips very usfull, of course these tips becuas
of all years working in access. really greet site.
my Quation:
is this away to change fonts in reports so the...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |