r/Python • • Mar 03 '16

Top 30 Mind Bending Python Interview Questions

https://intellipaat.com/interview-question/python-interview-questions/
0 Upvotes

8 comments sorted by

View all comments

1

u/[deleted] Mar 03 '16 edited Mar 03 '16

Here's a mind bender...

def foo():
    a = []
    a.extend([a] for _ in range(10))
    del a

Why does this fail with a syntax error in Python 2?

Edit: bracketed too much.

2

u/[deleted] Mar 03 '16

it doesn't

1

u/[deleted] Mar 03 '16

...fuck, I always remember that wrong. Fixed now.