I was trying to create a shortest-possible code for a puzzle, and the question came to mind trying to do something like this: 

`zip(l=[1,2,3,4,5],l[1:])` 

So I was wondering, is there a way to produce a value, assign it to a variable and use that variable on the very same line/function call?

EDIT:To clarify things, I am aware that this thing is not recommended nor good nor does it yield faster results. Also, the essence of the question is assignment and reusing of the same variable in the same function call. The list is produced using input, the static list here is for the example only. In a situation like this, I would like to avoid repeating the same task twice while I have already produced the result somewhere.
['https://Stackoverflow.com/questions/39191276', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1774080/']
If this is a code golf thing so it **must** be a single statement, then this works in Python 2:

```
print[zip(l,l[1:])for l in[[1,2,3,4,5]]][0]

```

**output**

```
[(1, 2), (2, 3), (3, 4), (4, 5)]

```

Otherwise, 

```
l=[1,2,3,4,5];print zip(l,l[1:])

```

is shorter, and **far** more sensible than the list comprehension abuse shown above.

Many languages in the C family permit assignment to variables inside expressions. This can be convenient but it has also led to numerous bugs, and most modern compilers will generate warnings if an assignment is detected inside an `if` condition (for example).

It was an intentional design decision to not allow that sort of thing in Python. Thus a Python assignment statement is *not* an expression, and so it doesn't have a value.

BTW, the Python data model is quite different to that of many other languages. [Python doesn't really have variables](http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables) that are containers for values, it has objects that may be bound to names.

---

Note that in Python 3 `zip` returns an iterator, not a list, so if you want to produce a list you'd need to wrap the `zip` call with `list()`.
Of course, you can always do this:

```
l = range(1, 6); zip(l, l[1:])

```

but I guess that's not what you wanted. :-)

There is a relatively clean way

```
(lambda l: zip(l, l[1:]))(range(1, 6))

```

BTW that function is defined in [itertools recipes](https://docs.python.org/3.6/library/itertools.html#itertools-recipes) as pairwise, so `pairwise(range(1, 6))` is probably the most direct way. You only need to write an import hook that imports Python functions from web pages. :-D

And there is a nice convoluted way

```
next(zip(l, l[1:]) for l in [range(1, 6)])

```

If you want more ideas, just say so. :-)